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_after(
&self,
view_id: &str,
cursor: &str,
limit: Option<usize>,
) -> Vec<(String, Value)>
pub async fn get_after( &self, view_id: &str, cursor: &str, limit: Option<usize>, ) -> Vec<(String, Value)>
Get entities with _seq greater than the provided cursor.
Returns entities that have been updated after the given cursor, sorted by _seq in ascending order. Useful for resuming from a specific point in the stream.
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
Sourcepub async fn remove(&self, view_id: &str, key: &str) -> Option<Value>
pub async fn remove(&self, view_id: &str, key: &str) -> Option<Value>
Remove one entity after a source-wide delete.
Sourcepub fn snapshot_config(&self) -> SnapshotBatchConfig
pub fn snapshot_config(&self) -> SnapshotBatchConfig
Get the snapshot batch configuration
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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more