/// Insert a key-value pair into the cache.
/// If key was not present, a [`None`] is returned, else the value is updated and the old value is returned.  
///
/// # Example
/// ```
/// use engine::store::Cache;
/// use std::time::Duration;
///
/// let mut cache = Cache::new();
///
/// let key: &'static str = "key";
/// let value: &'static str = "value";
///
/// let insert = cache.insert(key, value, None);
///
/// assert_eq!(cache.get(&key), Some(&value));
/// assert!(insert.is_none());
/// ```
Insert a key-value pair into the cache.
If key was not present, a [`None`] is returned, else the value is updated and the old value is returned.
Insert a key - value pair into the cache . If key was not present a [ ` None ` ] is returned else the value is updated and the old value is returned .
pub fn insert(&mut self, key: K, value: V, lifetime: Option<Duration>) -> Option<V> {
        let now = SystemTime::now();
        self.try_remove_expired_items(now);
        self.table
            .insert(key, Value::new(value, lifetime))
            .filter(|value| !value.has_expired(now))
            .map(|value| value.val)
    }
pub fn insert ( & mut self , key : K , value : V , lifetime : Option < Duration > ) -> Option < V > { let now = SystemTime :: now ( ) ; self . try_remove_expired_items ( now ) ; self . table . insert ( key , Value :: new ( value , lifetime ) ) . filter ( | value | ! value . has_expired ( now ) ) . map ( | value | value . val ) }
Insert a key-value pair into the cache.
Insert a key - value pair into the cache .
&mut self
key
K
value
V
lifetime
Option<Duration>
example
```
use engine::store::Cache;
use std::time::Duration.

let mut cache = Cache::new().

let key: &'static str = "key";
let value: &'static str = "value".

let insert = cache.insert(key, value, None).

assert_eq!(cache.get(&key), Some(&value));
assert!(insert.is_none());
```
` ` ` use engine :: store :: Cache ; use std :: time :: Duration . let mut cache = Cache :: new () . let key : & ' static str = " key " ; let value : & ' static str = " value " . let insert = cache . insert ( key value None ) . assert_eq! ( cache . get ( &key ) Some ( &value )) ; assert! ( insert . is_none () ) ; ` ` `