Struct writium_cache::Cache
[−]
[src]
pub struct Cache<T: 'static> { /* fields omitted */ }Cache for each Writium Api. Any Writium Api can be composited with this struct for cache.
Methods
impl<T: 'static> Cache<T>[src]
fn new<Src>(capacity: usize, src: Src) -> Cache<T> where
Src: 'static + CacheSource<Value = T>, [src]
Src: 'static + CacheSource<Value = T>,
fn create(&self, id: &str) -> Result<Arc<RwLock<T>>>[src]
Get the object identified by given ID. If the object is not cached, try recovering its cache from provided source. If there is no space for another object, the last recently accessed cache will be disposed.
fn get(&self, id: &str) -> Result<Arc<RwLock<T>>>[src]
Get the object identified by given ID. If the object is not cached, error will be returned. If there is no space for another object, the last recently accessed cache will be disposed.
fn remove(&self, id: &str) -> Result<()>[src]
Remove the object identified by given ID.
fn capacity(&self) -> usize[src]
The maximum number of items can be cached at a same time.
fn len(&self) -> usize[src]
Get the number of items cached.
Trait Implementations
impl<T: Clone + 'static> Clone for Cache<T>[src]
fn clone(&self) -> Cache<T>[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more