pub struct LookupMemoryCache { /* private fields */ }Expand description
quick_cache-backed in-memory lookup table cache.
Wraps [quick_cache::sync::Cache] with lookup-table semantics (composite
table-scoped keys, lazy TTL expiry). Designed for Ring 0 (< 500ns per
operation).
§Thread safety
quick_cache::sync::Cache is internally sharded with per-shard locks held
only for the duration of a map operation. LookupMemoryCache is
Send + Sync.
Implementations§
Source§impl LookupMemoryCache
impl LookupMemoryCache
Sourcepub fn new(table_id: u32, config: LookupMemoryCacheConfig) -> Self
pub fn new(table_id: u32, config: LookupMemoryCacheConfig) -> Self
Create a new cache with the given configuration.
Sourcepub fn with_defaults(table_id: u32) -> Self
pub fn with_defaults(table_id: u32) -> Self
Create a cache with default configuration.
Sourcepub fn get_cached(&self, key: &[u8]) -> LookupResult
pub fn get_cached(&self, key: &[u8]) -> LookupResult
Look up a key in the in-memory cache only (Ring 0, < 500ns).
When a TTL is configured, an entry older than the TTL is dropped and
reported as a miss (lazy expiry), so the caller re-fetches a fresh value
from the source. The removal re-checks expiry under the shard lock
(remove_if), so a fresh value racing in between the read and the
removal is preserved.
Sourcepub fn insert(&self, key: &[u8], value: RecordBatch)
pub fn insert(&self, key: &[u8], value: RecordBatch)
Insert or update a cached entry. The TTL clock starts now.
Sourcepub fn invalidate(&self, key: &[u8])
pub fn invalidate(&self, key: &[u8])
Invalidate a cached entry.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for LookupMemoryCache
impl !UnwindSafe for LookupMemoryCache
impl Freeze for LookupMemoryCache
impl Send for LookupMemoryCache
impl Sync for LookupMemoryCache
impl Unpin for LookupMemoryCache
impl UnsafeUnpin for LookupMemoryCache
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].