| Crates.io | vsdb_slot_db |
| lib.rs | vsdb_slot_db |
| version | 7.1.0 |
| created_at | 2023-06-12 11:22:04.592528+00 |
| updated_at | 2025-12-06 07:43:37.550274+00 |
| description | A skip-list like index cache |
| homepage | https://github.com/rust-util-collections/vsdb |
| repository | https://github.com/rust-util-collections/vsdb |
| max_upload_size | |
| id | 888100 |
| size | 73,826 |
A skip-list-like index for efficient, timestamp-based paged queries.
This crate provides SlotDB, a data structure that uses a tiered, skip-list-like index to enable fast pagination and range queries over large, ordered datasets. It is ideal for applications where data is associated with a "slot" (such as a timestamp or block number) and needs to be queried in pages.
Add this to your Cargo.toml:
[dependencies]
vsdb_slot_db = "7.0.0"
SlotDB provides an efficient way to query large, ordered datasets in pages.
use vsdb_slot_db::SlotDB;
// Create a new SlotDB with a tier capacity of 10 and normal order.
let mut db = SlotDB::<String>::new(10, false);
// Insert some keys into different slots.
db.insert(100, "entry_a".to_string()).unwrap();
db.insert(100, "entry_b".to_string()).unwrap();
db.insert(200, "entry_c".to_string()).unwrap();
db.insert(300, "entry_d".to_string()).unwrap();
// Check the total number of entries.
assert_eq!(db.total(), 4);
// Get entries by page.
// Get the first page with a size of 2, in reverse order.
let entries = db.get_entries_by_page(2, 0, true);
assert_eq!(entries, vec!["entry_d".to_string(), "entry_c".to_string()]);
// Get entries within a slot range.
let entries_in_slot = db.get_entries_by_page_slot(Some(100), Some(100), 10, 0, false);
assert_eq!(entries_in_slot.len(), 2);
assert!(entries_in_slot.contains(&"entry_a".to_string()));
assert!(entries_in_slot.contains(&"entry_b".to_string()));
For API examples, see API Examples.
This project is licensed under the MIT license.