pub struct PrefixCache { /* private fields */ }Expand description
Main prefix cache manager
Implementations§
Source§impl PrefixCache
impl PrefixCache
Sourcepub fn new(
max_sessions: usize,
ttl_seconds: u64,
frequency_threshold: usize,
session_dir: Option<PathBuf>,
) -> Result<Self>
pub fn new( max_sessions: usize, ttl_seconds: u64, frequency_threshold: usize, session_dir: Option<PathBuf>, ) -> Result<Self>
Sourcepub fn find_prefix_session(
&self,
text: &str,
tokens: &[i32],
) -> Option<(usize, Arc<SessionData>)>
pub fn find_prefix_session( &self, text: &str, tokens: &[i32], ) -> Option<(usize, Arc<SessionData>)>
Check if a text has a cached prefix and return the session
Sourcepub fn register_prefix(
&self,
text: &str,
tokens: &[i32],
session_data: Vec<u8>,
) -> Result<()>
pub fn register_prefix( &self, text: &str, tokens: &[i32], session_data: Vec<u8>, ) -> Result<()>
Register a new prefix for caching
§Errors
Returns an error if the cache is full and cannot evict enough entries
Sourcepub fn stats(&self) -> PrefixCacheStats
pub fn stats(&self) -> PrefixCacheStats
Get cache statistics
Auto Trait Implementations§
impl Freeze for PrefixCache
impl !RefUnwindSafe for PrefixCache
impl Send for PrefixCache
impl Sync for PrefixCache
impl Unpin for PrefixCache
impl UnsafeUnpin for PrefixCache
impl !UnwindSafe for PrefixCache
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more