pub struct ResultCache { /* private fields */ }Expand description
LRU + version-stamped result cache.
Implementations§
Source§impl ResultCache
impl ResultCache
Sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Create a new cache with the default capacity.
Sourcepub fn with_capacity(cap: NonZeroUsize) -> Self
pub fn with_capacity(cap: NonZeroUsize) -> Self
Create a new cache with the given capacity.
Sourcepub fn normalize_query(query: &str) -> String
pub fn normalize_query(query: &str) -> String
Normalize a query string: lowercase + collapse whitespace.
Sourcepub fn make_key(query: &str, user: Option<&str>) -> CacheKey
pub fn make_key(query: &str, user: Option<&str>) -> CacheKey
Build a cache key from a query and an optional user.
Sourcepub fn get(&self, key: &CacheKey) -> Option<Vec<MessageId>>
pub fn get(&self, key: &CacheKey) -> Option<Vec<MessageId>>
Look up an entry. Returns Some(ids) only if the entry exists AND its
stamp matches the current global version (i.e. it has not been
invalidated by a write).
Sourcepub fn put(&self, key: CacheKey, ids: Vec<MessageId>)
pub fn put(&self, key: CacheKey, ids: Vec<MessageId>)
Insert (or replace) an entry stamped at the current version.
Sourcepub fn invalidate_all(&self)
pub fn invalidate_all(&self)
Bump the invalidation version. Called after any successful index mutation (add or delete). All subsequent lookups will treat existing entries as stale until they are re-populated.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ResultCache
impl RefUnwindSafe for ResultCache
impl Send for ResultCache
impl Sync for ResultCache
impl Unpin for ResultCache
impl UnsafeUnpin for ResultCache
impl UnwindSafe for ResultCache
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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