pub struct TripleCache<K, V> { /* private fields */ }Expand description
Generic LRU/LFU/FIFO/TTL cache for RDF data.
Thread-safe via an internal Mutex. The policy is selected at construction time.
§Type Parameters
K: Cache key type (must implementEq + Hash + Clone).V: Cached value type (must implementClone).
Implementations§
Source§impl<K: Eq + Hash + Clone, V: Clone> TripleCache<K, V>
impl<K: Eq + Hash + Clone, V: Clone> TripleCache<K, V>
Sourcepub fn new(capacity: usize, policy: CachePolicy, ttl: Option<Duration>) -> Self
pub fn new(capacity: usize, policy: CachePolicy, ttl: Option<Duration>) -> Self
Create a new cache with the given capacity, eviction policy, and optional TTL.
Sourcepub fn get(&self, key: &K) -> Option<V>
pub fn get(&self, key: &K) -> Option<V>
Look up key and return a clone of the value if present and not expired.
Sourcepub fn remove(&self, key: &K) -> bool
pub fn remove(&self, key: &K) -> bool
Remove key from the cache. Returns true if it was present.
pub fn is_empty(&self) -> bool
Sourcepub fn stats(&self) -> Arc<CacheStats>
pub fn stats(&self) -> Arc<CacheStats>
Shared statistics counter.
Auto Trait Implementations§
impl<K, V> !Freeze for TripleCache<K, V>
impl<K, V> RefUnwindSafe for TripleCache<K, V>
impl<K, V> Send for TripleCache<K, V>
impl<K, V> Sync for TripleCache<K, V>
impl<K, V> Unpin for TripleCache<K, V>
impl<K, V> UnsafeUnpin for TripleCache<K, V>
impl<K, V> UnwindSafe for TripleCache<K, V>
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