pub struct EntityCache { /* private fields */ }Expand description
Entity cache that maintains full projected entities with LRU eviction.
The cache is populated as mutations flow through the projector, regardless of subscriber state. When a new subscriber connects, they receive snapshots of all cached entities for their requested view.
Implementations§
Source§impl EntityCache
impl EntityCache
Sourcepub fn with_config(config: EntityCacheConfig) -> Self
pub fn with_config(config: EntityCacheConfig) -> Self
Create a new entity cache with custom configuration
pub async fn upsert(&self, view_id: &str, key: &str, patch: Value)
pub async fn upsert_with_append( &self, view_id: &str, key: &str, patch: Value, append_paths: &[String], )
Sourcepub async fn get_all(&self, view_id: &str) -> Vec<(String, Value)>
pub async fn get_all(&self, view_id: &str) -> Vec<(String, Value)>
Get all cached entities for a view.
Returns a vector of (key, entity) pairs for sending as snapshots to new subscribers.
Sourcepub async fn get(&self, view_id: &str, key: &str) -> Option<Value>
pub async fn get(&self, view_id: &str, key: &str) -> Option<Value>
Get a specific entity from the cache
pub async fn clear_all(&self)
pub async fn stats(&self) -> CacheStats
Trait Implementations§
Source§impl Clone for EntityCache
impl Clone for EntityCache
Source§fn clone(&self) -> EntityCache
fn clone(&self) -> EntityCache
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 moreAuto Trait Implementations§
impl Freeze for EntityCache
impl !RefUnwindSafe for EntityCache
impl Send for EntityCache
impl Sync for EntityCache
impl Unpin for EntityCache
impl !UnwindSafe for EntityCache
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