https://github.com/adityamotale/turbo_cache
A persistent, file-based Key-Value store implementation in Rust.
https://github.com/adityamotale/turbo_cache
database kv-store rust
Last synced: about 1 year ago
JSON representation
A persistent, file-based Key-Value store implementation in Rust.
- Host: GitHub
- URL: https://github.com/adityamotale/turbo_cache
- Owner: AdityaMotale
- Created: 2024-12-27T14:16:12.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-12-27T14:17:42.000Z (over 1 year ago)
- Last Synced: 2025-04-15T17:12:43.958Z (about 1 year ago)
- Topics: database, kv-store, rust
- Language: Rust
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TurboCache 🚀📦
A persistent, file-based Key-Value store implementation in Rust.
It supports fixed-size KV storage with automatic resizing.
## Features
- File-based storage with linear probing for collision resolution
- Automatic table resizing when load factor exceeds 75%
- Fixed-size keys (8 bytes) and values (56 bytes)
- FNV-1a hash function implementation
## Usage
```rust
use turbo_cache::file_hash::FileHash;
fn main() -> std::io::Result<()> {
let mut turbo_cache = FileHash::init()?;
// Store Entries
turbo_cache.set("user_1", "John Doe")?;
turbo_cache.set("user_2", "Jane Smith")?;
// Fetch Entries
assert_eq!(turbo_cache.get("user_1")?, Some("John Doe".to_string()));
// Delete Entries
assert_eq!(turbo_cache.del("user_2")?, Some("Jane Smith".to_string()));
assert_eq!(turbo_cache.get("user_2")?, None);
Ok(())
}
```
## API
- `FileHash::init() -> io::Result`
Creates or opens hash table stored in `hash.tc`.
- `set(&mut self, key: &str, value: &str) -> io::Result<()>`
Inserts or updates a key-value pair.
- `get(&mut self, key: &str) -> io::Result>`
Retrieves value for given key.
- `del(&mut self, key: &str) -> io::Result>`
Removes key-value pair and returns removed value.
## Performance
Benchmarks conducted on:
- CPU: Intel Core i5-10300H @ 2.50GHz
- RAM: 16GB
- OS: Windows 64-bit (WSL2 Ubuntu 24.04.1 LTS)
| Operation | Time |
| --------------- | --------- |
| 100K insertions | ~174.79ms |
| 100K retrievals | ~70.21ms |
| 100K deletions | ~161.62ms |