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 put(
&self,
query_key: u64,
security_hash: u64,
response: Arc<Value>,
accessed_views: Vec<String>,
) -> Result<()>
pub fn put( &self, query_key: u64, security_hash: u64, response: Arc<Value>, accessed_views: Vec<String>, ) -> Result<()>
Store a response in the cache.
§Errors
This method is infallible with the moka backend and always returns Ok.
Auto Trait Implementations§
impl !Freeze for ResponseCache
impl !RefUnwindSafe for ResponseCache
impl Send for ResponseCache
impl Sync for ResponseCache
impl Unpin for ResponseCache
impl UnsafeUnpin for ResponseCache
impl !UnwindSafe for ResponseCache
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more