pub struct ResponseCache { /* private fields */ }Expand description
Executor-level cache for projected GraphQL responses.
Stores the final serialized response keyed by (query_hash, security_hash).
On hit, the entire projection + RBAC + serialization pipeline is skipped.
§Thread Safety
moka::sync::Cache is Send + Sync with lock-free reads. The view reverse
index uses DashMap (fine-grained shard locking). There is no global mutex
on the read path.
Implementations§
Source§impl ResponseCache
impl ResponseCache
Sourcepub fn new(config: ResponseCacheConfig) -> Self
pub fn new(config: ResponseCacheConfig) -> Self
Create a new response cache from configuration.
Sourcepub const fn is_enabled(&self) -> bool
pub const fn is_enabled(&self) -> bool
Whether the response cache is enabled.
Sourcepub fn get(
&self,
query_key: u64,
security_hash: u64,
) -> Result<Option<Arc<Value>>>
pub fn get( &self, query_key: u64, security_hash: u64, ) -> Result<Option<Arc<Value>>>
Look up a cached response.
§Errors
This method is infallible with the moka backend and always returns Ok.
Sourcepub fn invalidation_generation(&self) -> u64
pub fn invalidation_generation(&self) -> u64
Snapshot of the invalidation generation, for fencing a cache write (#1079).
Take this before the work whose result is being cached, and pass it to
put.
Sourcepub fn put(
&self,
query_key: u64,
security_hash: u64,
response: Arc<Value>,
accessed_views: Vec<String>,
fence: Option<u64>,
) -> Result<()>
pub fn put( &self, query_key: u64, security_hash: u64, response: Arc<Value>, accessed_views: Vec<String>, fence: Option<u64>, ) -> Result<()>
Store a response in the cache.
fence is a snapshot from invalidation_generation
taken before the work that produced response. If an invalidation landed since,
the entry is discarded rather than stored — the caller keeps its response, it is
simply not cached. None stores unconditionally.
§Errors
This method is infallible with the moka backend and always returns Ok.