| Crates.io | lrust_cache |
| lib.rs | lrust_cache |
| version | 0.1.0 |
| created_at | 2025-01-14 19:10:00.15022+00 |
| updated_at | 2025-01-14 19:10:00.15022+00 |
| description | A high-performance LRU cache implementation in Rust |
| homepage | |
| repository | https://github.com/lonless9/LrustCache |
| max_upload_size | |
| id | 1516484 |
| size | 89,225 |
A concurrent LRU (Least Recently Used) cache implementation in Rust, focusing on simplicity and performance.
⚠️ Disclaimer
- This project is in early development stage and the API may undergo significant changes
- The code has not undergone comprehensive security audits or performance testing
- NOT recommended for production use or handling critical data
The following features are under development:
Currently provides two implementations:
BasicLruCache
ShardedLruCache
Add this to your Cargo.toml:
[dependencies]
lrust_cache = "0.1.0" # Note: Version may be unstable
use lrust_cache::{Cache, BasicLruCache};
// Create a cache with capacity of 1000
let mut cache = BasicLruCache::new(1000);
// Warning: BasicLruCache is NOT thread-safe!
cache.put("key1", "value1");
if let Some(value) = cache.get(&"key1") {
println!("Got value: {}", value);
}
For concurrent scenarios, use the sharded implementation:
use lrust_cache::{Cache, ShardedLruCache};
// Create a sharded cache with total capacity of 1000
let cache = ShardedLruCache::new(1000);
// ShardedLruCache supports concurrent access
cache.put("key1", "value1");
if let Some(value) = cache.get(&"key1") {
println!("Got value: {}", value);
}
⚠️ Note: The following performance data is for reference only. Actual performance may vary depending on usage scenarios
Test scenario:
Preliminary results (operations per second):
Complete benchmark code is available in the cpp_bench directory. It's recommended to conduct your own performance testing before use.
BasicLruCache:
ShardedLruCache:
⚠⚠️ C++ integration API is under development and subject to change
#include "rust_cache.h"
// Create cache
RustCache cache(100000);
// Basic operations
cache.put("key1", "value1");
std::string value = cache.get("key1");