pub struct Cache { /* private fields */ }Expand description
Concurrent key-value cache with named buckets.
Uses DashMap internally for lock-free concurrent reads. Create named buckets for different entity types (products, listings, etc.).
Implementations§
Source§impl Cache
impl Cache
pub fn new() -> Self
Sourcepub fn with_buckets(names: &[&str]) -> Self
pub fn with_buckets(names: &[&str]) -> Self
Create a set of named buckets upfront.
Sourcepub fn set(&self, bucket: &str, key: String, value: String)
pub fn set(&self, bucket: &str, key: String, value: String)
Set a value in a named bucket (creates the bucket if it doesn’t exist).
Sourcepub fn remove(&self, bucket: &str, key: &str) -> Option<String>
pub fn remove(&self, bucket: &str, key: &str) -> Option<String>
Remove a value from a named bucket.
Sourcepub fn clear_bucket(&self, bucket: &str)
pub fn clear_bucket(&self, bucket: &str)
Clear all entries in a specific bucket.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Cache
impl !RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnsafeUnpin for Cache
impl !UnwindSafe for Cache
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