[−][src]Struct simple_cache_rs::SimpleCache
Implementations
impl<K: Eq + Hash + Clone, V: Clone> SimpleCache<K, V>[src]
pub fn new() -> SimpleCache<K, V>[src]
Returns a new instance of SimpleCache
use simple_cache_rs::SimpleCache; let mut cache: SimpleCache<i32, String> = SimpleCache::new();
pub fn with_timeout(timeout: Duration) -> SimpleCache<K, V>[src]
Returns a new instance of SimpleCache with a timeout for values
use simple_cache_rs::SimpleCache; use std::time::Duration; let mut cache: SimpleCache<i32, String> = SimpleCache::with_timeout(Duration::new(100, 0));
pub fn get(&mut self, key: &K) -> Option<V>[src]
Get a value optionally from the cache, if the value is expired this method will return None and delete the value lazily from the cache.
use simple_cache_rs::SimpleCache; let mut cache: SimpleCache<i32, String> = SimpleCache::new(); cache.get(&1);
pub fn keys(&self) -> Vec<K>[src]
Get all keys that are in the cache
use simple_cache_rs::SimpleCache; let mut cache: SimpleCache<i32, String> = SimpleCache::new(); cache.keys();
pub fn values(&self) -> Vec<V>[src]
Get all values that are in the cache
use simple_cache_rs::SimpleCache; let mut cache: SimpleCache<i32, String> = SimpleCache::new(); cache.values();
pub fn insert_batch(&mut self, items: Vec<(K, V)>)[src]
Insert a batch of items into the cache
use simple_cache_rs::SimpleCache; let mut cache: SimpleCache<i32, String> = SimpleCache::new(); let items = vec!((1, String::from("a")), (2, String::from("b"))); cache.insert_batch(items);
pub fn insert(&mut self, key: K, value: V) -> Option<V>[src]
Insert an item into the cache
use simple_cache_rs::SimpleCache; let mut cache: SimpleCache<i32, String> = SimpleCache::new(); cache.insert(1, String::from("a"));
pub fn delete(&mut self, key: &K) -> Option<V>[src]
Remove an entry from the cache
use simple_cache_rs::SimpleCache; let mut cache: SimpleCache<i32, String> = SimpleCache::new(); cache.insert(1, String::from("a")); cache.delete(&1);
Trait Implementations
impl<K: Clone, V: Clone> Clone for SimpleCache<K, V>[src]
pub fn clone(&self) -> SimpleCache<K, V>[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<K: Debug, V: Debug> Debug for SimpleCache<K, V>[src]
Auto Trait Implementations
impl<K, V> RefUnwindSafe for SimpleCache<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for SimpleCache<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> Sync for SimpleCache<K, V> where
K: Sync,
V: Sync,
K: Sync,
V: Sync,
impl<K, V> Unpin for SimpleCache<K, V> where
K: Unpin,
V: Unpin,
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for SimpleCache<K, V> where
K: UnwindSafe,
V: UnwindSafe,
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,