pub struct DistributedCache { /* private fields */ }Expand description
Distributed cache implementation with local fallback.
This cache combines local in-memory storage with distributed storage, providing fast access with shared state across multiple instances.
§Examples
use ultrafast_models_sdk::cache::{DistributedCache, Cache, CachedResponse};
use std::time::Duration;
let cache = DistributedCache::new(500); // 500 local entries
let response = CachedResponse::new(chat_response, Duration::from_secs(3600));
cache.set("key", response, Duration::from_secs(3600));
if let Some(cached) = cache.get("key") {
println!("Cache hit from distributed cache");
}Implementations§
Trait Implementations§
Source§impl Cache for DistributedCache
impl Cache for DistributedCache
Source§fn get(&self, key: &str) -> Option<CachedResponse>
fn get(&self, key: &str) -> Option<CachedResponse>
Retrieve a cached response by key. Read more
Source§fn set(&self, key: &str, response: CachedResponse, ttl: Duration)
fn set(&self, key: &str, response: CachedResponse, ttl: Duration)
Store a response in the cache. Read more
Source§fn invalidate(&self, key: &str)
fn invalidate(&self, key: &str)
Remove a specific entry from the cache. Read more
Auto Trait Implementations§
impl Freeze for DistributedCache
impl !RefUnwindSafe for DistributedCache
impl Send for DistributedCache
impl Sync for DistributedCache
impl Unpin for DistributedCache
impl UnwindSafe for DistributedCache
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