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
47
48
49
//! # **Shmap**
//!
//! **A key-value store based on linux shared-memory files (shm) for persisting state across program restarts.**
//!
//! ## Features
//!
//! - Items are stored in the linux shared memory: it uses `shm_open` to create file in the ramdisk (/dev/shm), then they are mapped in memory with mmap.
//!
//! - Concurrent access to items it provided thanks to `named-lock` mutexes.
//!
//! - Value serialization can be made transparently with serde (`bincode`), so don't forget to use [serde_bytes](https://crates.io/crates/serde_bytes) to enable optimized handling of `&[u8]` and `Vec<u8>` !
//!
//! - You can protect your data with AES256-GCM encryption.
//!
//! - You can add a TTL so that your items won't be available anymore after this duration.
//!
//! ## Example
//!
//! ```rust
//! use shmap::{Shmap, ShmapError};
//! use std::time::Duration;
//!
//! fn main() -> Result<(), ShmapError> {
//! let shmap = Shmap::new();
//!
//! shmap.insert("key", "value")?;
//! let value = shmap.get("key")?;
//!
//! assert_eq!(Some("value".to_string()), value);
//!
//! // We strongly advise to use Shmap with TTL to avoid opening too many file descriptors,
//! // or using too much RAM
//! shmap.insert_with_ttl("key", "temporary_value", Duration::from_secs(60))?;
//!
//! shmap.remove("key")?;
//!
//! Ok(())
//! }
//! ```
pub use ShmapError;
pub use Shmap;