Skip to main content

Module memory

Module memory 

Source
Expand description

In-memory storage utilities for WASM-compatible caching.

This module provides a generic MemoryStore that can be used to cache data in memory, particularly useful for WASM environments where filesystem access is limited or unavailable.

§Example

use rh_foundation::memory::{MemoryStore, MemoryStoreConfig};

// Create a store with default config
let store: MemoryStore<String> = MemoryStore::new(MemoryStoreConfig::default());

// Insert and retrieve values
store.insert("key1".to_string(), "value1".to_string());
assert_eq!(store.get(&"key1".to_string()), Some("value1".to_string()));

// Check if key exists
assert!(store.contains(&"key1".to_string()));

// Remove a value
store.remove(&"key1".to_string());
assert!(!store.contains(&"key1".to_string()));

Structs§

MemoryStore
A thread-safe in-memory key-value store.
MemoryStoreConfig
Configuration for a memory store.
MemoryStoreStats
Statistics for a memory store.