Expand description
In-Memory Store - Generic Testing and Prototyping Utility
Provides a thread-safe, async-compatible in-memory storage implementation for use in testing, prototyping, and development environments.
§Features
- Generic storage for any
Clone + Send + Synctype - Soft delete with trash/restore functionality
- Pagination support
- Thread-safe using
RwLock - Async-compatible
§Example
ⓘ
use backbone_orm::InMemoryStore;
#[derive(Clone)]
struct User {
id: String,
name: String,
}
#[tokio::main]
async fn main() {
let store = InMemoryStore::<User>::new();
// Insert
let user = User { id: "1".to_string(), name: "Alice".to_string() };
store.insert("1".to_string(), user.clone()).await;
// Get
let found = store.get("1").await;
assert!(found.is_some());
// Soft delete
store.soft_delete("1").await;
assert!(store.get("1").await.is_none());
// Restore
store.restore("1").await;
assert!(store.get("1").await.is_some());
}Structs§
- InMemory
Store - Generic in-memory store for entities