Trait writium_cache::CacheSource [] [src]

pub trait CacheSource: 'static + Send + Sync {
    type Value: Clone;
    fn generate(&self, id: &str) -> Option<Self::Value>;

    fn dispose(&self, _id: &str, _obj: &mut Self::Value) { ... }
fn remove(&self, _id: &str, _obj: &mut Self::Value) { ... } }

Associated Types

Required Methods

Generate a new cached object. Return a value defined by default configurations. In the course of generation, no state should be created or written out of RAM, e.g., writing to files or calling to remote machines.

Provided Methods

Dispose a cached object. Implementations should write the value into a recoverable form of storage, e.g., serializing data into JSON, if necessary. Cache disposal is an optional process.

Remove a cached object. Implementations should remove any associated data from storage and invalidate any recoverability. Cache removal is an optional process.

Implementors