pub struct CachedResult {
pub result: Arc<Vec<JsonbValue>>,
pub accessed_views: Box<[ViewName]>,
pub cached_at: u64,
pub ttl_seconds: u64,
pub entity_refs: Box<[(String, String)]>,
pub epoch: u64,
}Expand description
Cached query result with metadata.
Stores the query result along with tracking information for TTL expiry, view-based invalidation, and monitoring.
Fields§
§result: Arc<Vec<JsonbValue>>The actual query result (JSONB array from database).
Wrapped in Arc for cheap cloning on cache hits (zero-copy).
accessed_views: Box<[ViewName]>Which views/tables this query accesses.
Format: [ViewName::from("v_user"), ViewName::from("v_post")]
Stored as a boxed slice of ViewName (each backed by Arc<str>)
so cloning a name into the reverse index is a cheap atomic ref-count
bump rather than a fresh heap allocation. Views are fixed at put()
time and never modified.
cached_at: u64When this entry was cached (Unix timestamp in seconds).
Wall-clock timestamp for debugging. TTL enforcement is handled by moka
internally via CacheEntryExpiry.
ttl_seconds: u64Per-entry TTL in seconds.
Overrides CacheConfig::ttl_seconds when set via put(..., Some(ttl)).
Read by CacheEntryExpiry::expire_after_create to tell moka the expiry.
entity_refs: Box<[(String, String)]>Entity references for selective entity-level invalidation.
Contains one (entity_type, entity_id) pair per row in result that has
a valid string in its "id" field. Empty for queries with no id column
or when put() is called without an entity_type.
Used by the eviction listener to clean up entity_index on eviction.
epoch: u64Process-unique identity of this cached entry instance.
Distinguishes an entry from its own replacement under the same cache key.
The reverse indexes register (cache_key, epoch) pairs so the eviction
listener can deregister exactly the instance being evicted and never the
live one that displaced it — see the module docs (#740).