Expand description
Redish - simple in-memory key-value database with TTL support
§Example
use std::time::Duration;
use redish::tree::Tree;
use bincode::{Decode, Encode};
#[derive(Debug, Encode, Decode, Clone)]
struct User {
user_id: u64,
username: String,
}
let user = User {user_id: 3, username: "JohnDoe2020".to_string()};
let mut tree = Tree::load_with_path("/path/to/db/with_file_name");
tree.put("key1".to_string().into_bytes(), "value".to_string().into_bytes());
tree.put_with_ttl("key2".to_string().into_bytes(), "value".to_string().into_bytes(), Some(Duration::from_secs(60)));
tree.put_typed::<User>("key3", &user);
Re-exports§
pub use crate::tree::Tree;
pub use crate::tree::DataValue;
pub use crate::tree::TreeSettings;
pub use crate::tree::TreeSettingsBuilder;
Modules§
Traits§
- Decode
- Trait that makes a type able to be decoded, akin to serde’s
DeserializeOwned
trait. - Encode
- Any source that can be encoded. This trait should be implemented for all types that you want to be able to use with any of the
encode_with
methods.