1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (C) 2024 Christian Mauduit <ufoot@ufoot.org>
//! [DiskLRU](https://gitlab.com/liberecofr/disklru) is an experimental LRU store implemented in [Rust](https://www.rust-lang.org/).
//!
//! It works as a simple key-value store and is powered by [sled](https://crates.io/crates/sled/)
//! which is _a lightweight pure-rust high-performance transactional embedded database_.
//!
//! It expires entries automatically passed a given number, following the LRU (least recently used) strategy,
//! which is a quite [common cache replacement policy]( https://en.wikipedia.org/wiki/Cache_replacement_policies).
//!
//! 
//!
//! # Examples
//!
//! ```
//! use disklru::Store;
//!
//! let mut store = Store::open_temporary(4).unwrap();
//! store.insert(&1, &10).unwrap();
//! store.insert(&2, &20).unwrap();
//! store.insert(&3, &30).unwrap();
//! store.insert(&4, &40).unwrap();
//! store.insert(&5, &50).unwrap();
//! // key1 has been dropped, size is limited to 4
//! assert_eq!(Some(2), store.lru().unwrap());
//! assert_eq!(Some(20), store.get(&2).unwrap());
//! // getting key2 has made key3 the least recently used item
//! assert_eq!(Some(3), store.lru().unwrap());
//! assert_eq!(Some(40), store.get(&4).unwrap());
//! // getting key4 makes it the most recently used item
//! assert_eq!("[3: 30, 5: 50, 2: 20, 4: 40]", format!("{}", store));
//! store.flush().unwrap(); // commit
//! ```
pub use *;
pub use *;
pub use *;