pub struct TemplateCache { /* private fields */ }Expand description
Template cache for compiled templates and metadata
Caches compiled Tera templates and tracks file modification times for hot-reload functionality.
Implementations§
Source§impl TemplateCache
impl TemplateCache
Sourcepub fn new(hot_reload: bool, ttl: Duration) -> Self
pub fn new(hot_reload: bool, ttl: Duration) -> Self
Create new template cache
§Arguments
hot_reload- Enable hot-reload for file changesttl- Cache time-to-live duration
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create cache with common settings (1 hour TTL, hot-reload enabled)
Sourcepub fn get_or_compile(
&self,
template_name: &str,
template_content: &str,
file_path: Option<&Path>,
) -> Result<String>
pub fn get_or_compile( &self, template_name: &str, template_content: &str, file_path: Option<&Path>, ) -> Result<String>
Get template from cache or compile if not cached/missing
§Arguments
template_name- Name of templatetemplate_content- Template contentfile_path- Optional file path for hot-reload
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Sourcepub fn evict_expired(&self) -> usize
pub fn evict_expired(&self) -> usize
Evict expired templates
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TemplateCache
impl RefUnwindSafe for TemplateCache
impl Send for TemplateCache
impl Sync for TemplateCache
impl Unpin for TemplateCache
impl UnwindSafe for TemplateCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more