pub struct AegMemoryEngine {
pub store: HashMap<String, String>,
pub collection_name: String,
}Expand description
IN-MEMORY KEY-VALUE STORE ENGINE
Fields§
§store: HashMap<String, String>§collection_name: StringImplementations§
Source§impl AegMemoryEngine
impl AegMemoryEngine
pub fn new(collection_name: &str) -> Self
Sourcepub fn insert(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn insert(&mut self, key: impl Into<String>, value: impl Into<String>)
Insert into current engine and update global in-memory cache (fast).
pub fn get(&self, key: &str) -> Option<String>
pub fn delete(&mut self, key: &str)
pub fn list(&self) -> Vec<(String, String)>
pub fn clear(&mut self)
Sourcepub fn save_to_disk(engine: &AegMemoryEngine) -> Result<(), String>
pub fn save_to_disk(engine: &AegMemoryEngine) -> Result<(), String>
Persist single engine to disk (synchronous) — same encryption as before.
Sourcepub fn save_all()
pub fn save_all()
Save ALL collections currently in memory to disk. This function clones the cache under the mutex and performs expensive work outside the lock.
Sourcepub fn load() -> Self
pub fn load() -> Self
Load engine from memory cache; otherwise load from disk; otherwise fresh engine.
Sourcepub fn start_background_saver(interval_seconds: u64)
pub fn start_background_saver(interval_seconds: u64)
Start a background thread to periodically save memory to disk. If already started, this is a no-op.
Sourcepub fn stop_background_saver()
pub fn stop_background_saver()
Signal the background saver to stop. Thread is detached so we can’t join; this just signals termination.
Trait Implementations§
Source§impl Clone for AegMemoryEngine
impl Clone for AegMemoryEngine
Source§fn clone(&self) -> AegMemoryEngine
fn clone(&self) -> AegMemoryEngine
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AegMemoryEngine
impl Debug for AegMemoryEngine
Source§impl<'de> Deserialize<'de> for AegMemoryEngine
impl<'de> Deserialize<'de> for AegMemoryEngine
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for AegMemoryEngine
impl RefUnwindSafe for AegMemoryEngine
impl Send for AegMemoryEngine
impl Sync for AegMemoryEngine
impl Unpin for AegMemoryEngine
impl UnwindSafe for AegMemoryEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more