pub struct ReactorCache<K, V, E> { /* private fields */ }
Implementations§
Source§impl<K: Clone + Eq + Hash, V: Weighted, E: Clone + Debug> ReactorCache<K, V, E>
Core methods for interacting with the cache
impl<K: Clone + Eq + Hash, V: Weighted, E: Clone + Debug> ReactorCache<K, V, E>
Core methods for interacting with the cache
Sourcepub fn new(capacity: usize, handle: Handle) -> Selfwhere
K: 'static,
V: 'static,
E: 'static,
pub fn new(capacity: usize, handle: Handle) -> Selfwhere
K: 'static,
V: 'static,
E: 'static,
Creates a new Reactor Cache with the given capacity, which runs in handle
’s event-loop
Sourcepub fn stats(&self) -> Receiver<CacheStats>
pub 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();
Sourcepub fn get(&self, k: K) -> GetHandle<V, E>
pub 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();
pub fn get_if_resident(&self, k: K) -> GetHandle<V, E>
pub 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,
pub fn load<F>(&self, k: K, f: F) -> LoadHandle<F, V, E>where
F: Future<Item = V, Error = E>,
pub fn evict(&self, k: K) -> Receiver<()>
Auto Trait Implementations§
impl<K, V, E> Freeze for ReactorCache<K, V, E>
impl<K, V, E> RefUnwindSafe for ReactorCache<K, V, E>
impl<K, V, E> Send for ReactorCache<K, V, E>
impl<K, V, E> Sync for ReactorCache<K, V, E>
impl<K, V, E> Unpin for ReactorCache<K, V, E>
impl<K, V, E> UnwindSafe for ReactorCache<K, V, E>
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