pub struct RegexCache { /* private fields */ }Expand description
A cache for compiled regular expressions.
The cache uses LRU (Least Recently Used) eviction when full.
Implementations§
Source§impl RegexCache
impl RegexCache
Sourcepub fn with_default_size() -> Self
pub fn with_default_size() -> Self
Create a new regex cache with default size.
Sourcepub fn get_or_compile(&self, pattern: &str) -> Result<Arc<Regex>, Error>
pub fn get_or_compile(&self, pattern: &str) -> Result<Arc<Regex>, Error>
Get or compile a regex pattern.
Returns a cached regex if available, otherwise compiles and caches it.
§Errors
Returns an error if the pattern is invalid.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics.
Sourcepub fn total_hits(&self) -> usize
pub fn total_hits(&self) -> usize
Get the total number of cache hits.
Sourcepub fn total_misses(&self) -> usize
pub fn total_misses(&self) -> usize
Get the total number of cache misses.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RegexCache
impl RefUnwindSafe for RegexCache
impl Send for RegexCache
impl Sync for RegexCache
impl Unpin for RegexCache
impl UnwindSafe for RegexCache
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