Crate endorphin

Source
Expand description

Endorphin is key-value based in-memory cache library with custom expiration policies.

Basically, endorphin provides four pre-defined policies.

You can also define new custom policies by using ExpirePolicy.

§Examples

use std::thread::sleep;
use std::time::Duration;

use endorphin::policy::TTLPolicy;
use endorphin::HashMap;

fn main() {
    let mut cache = HashMap::new(TTLPolicy::new());

    cache.insert("Still", "Alive", Duration::from_secs(3));
    cache.insert("Gonna", "Die", Duration::from_secs(1));

    sleep(Duration::from_secs(1));

    assert_eq!(cache.get(&"Still"), Some(&"Alive"));
    assert_eq!(cache.get(&"Gonna"), None);
}

For more examples, visit here

Modules§

  • A hash map implemented with hashbrown internal. hashbrown: https://docs.rs/hashbrown/latest/hashbrown/index.html
  • An expiration policy including four pre-defined policies.
  • A hash set implemented with hashbrown internal. hashbrown: https://docs.rs/hashbrown/latest/hashbrown/index.html

Structs§