Struct reactor_cache::ReactorCache
[−]
[src]
pub struct ReactorCache<K, V, E> { /* fields omitted */ }
Methods
impl<K: Clone + Eq + Hash, V: Weighted, E: Clone + Debug> ReactorCache<K, V, E>
[src]
Core methods for interacting with the cache
fn new(capacity: usize, handle: Handle) -> Self where
K: 'static,
V: 'static,
E: 'static,
K: 'static,
V: 'static,
E: 'static,
Creates a new Reactor Cache with the given capacity, which runs in handle
's event-loop
fn stats(&self) -> Receiver<CacheStats>
Returns a future with a snapshot of the cache's stats. No guarnatees are made about when the snapshot is taken.
Example
Run a future that logs the cache stats:
let mut core = Core::new().expect("meltdown"); let cache = ReactorCache::<Int, Int, ()>::new(10, core.handle()); core.run(cache.stats().map(|s| println!("{:?}",s))).unwrap();
fn get(&self, k: K) -> GetHandle<V, E>
Returns a future with a snapshot of the cache's stats. No guarnatees are made about when the snapshot is taken.
Example
Run a future that logs the cache stats:
let mut core = Core::new().expect("meltdown"); let cache = ReactorCache::<Int, Int, ()>::new(10, core.handle()); core.run(cache.load_fn(Int(1), || core.run(cache.stats().map(|s| println!("{:?}",s))).unwrap();
fn get_if_resident(&self, k: K) -> GetHandle<V, E>
fn load_fn<F, T>(&self, k: K, f: F) -> LoadHandle<Lazy<F, T>, V, E> where
F: 'static + Send + FnOnce() -> T,
T: 'static + IntoFuture<Item = V, Error = E>,
T::Future: 'static + Send,
F: 'static + Send + FnOnce() -> T,
T: 'static + IntoFuture<Item = V, Error = E>,
T::Future: 'static + Send,
fn load<F>(&self, k: K, f: F) -> LoadHandle<F, V, E> where
F: Future<Item = V, Error = E>,
F: Future<Item = V, Error = E>,