pub struct GraphQlResponseCache { /* private fields */ }Expand description
Thread-safe GraphQL response cache supporting type- and field-level invalidation and stale-while-revalidate semantics.
Implementations§
Source§impl GraphQlResponseCache
impl GraphQlResponseCache
Sourcepub fn cached_response(&self, key: &ResponseCacheKey) -> Option<CachedResponse>
pub fn cached_response(&self, key: &ResponseCacheKey) -> Option<CachedResponse>
Look up a cached response.
Returns Some(CachedResponse) when the entry exists and is either
fresh or within the stale-while-revalidate window. Expired entries
are removed eagerly.
Sourcepub fn store_response(
&self,
key: ResponseCacheKey,
body: String,
policy: CachePolicy,
touched_types: Vec<String>,
touched_fields: Vec<String>,
)
pub fn store_response( &self, key: ResponseCacheKey, body: String, policy: CachePolicy, touched_types: Vec<String>, touched_fields: Vec<String>, )
Store a response in the cache.
Sourcepub fn invalidate_type(&self, type_name: &str) -> usize
pub fn invalidate_type(&self, type_name: &str) -> usize
Invalidate all entries that touched type_name.
Returns the number of entries evicted.
Sourcepub fn invalidate_field(&self, type_name: &str, field: &str) -> usize
pub fn invalidate_field(&self, type_name: &str, field: &str) -> usize
Invalidate all entries that touched field "type_name.field_name".
Returns the number of entries evicted.
Sourcepub fn warm_up(
&self,
tenant_id: Option<&str>,
queries: &[(String, Value)],
) -> Vec<ResponseCacheKey>
pub fn warm_up( &self, tenant_id: Option<&str>, queries: &[(String, Value)], ) -> Vec<ResponseCacheKey>
Pre-populate the cache by computing keys for a list of (query, variables) pairs.
This marks the slot as absent so callers know they need to prime the
actual responses. In practice, the warm-up caller would follow up with
store_response calls once results are fetched. Here we return the
computed keys so the caller can do so.
Sourcepub fn invalidate_tenant(&self, tenant_id: &str) -> usize
pub fn invalidate_tenant(&self, tenant_id: &str) -> usize
Remove all entries for a given tenant.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GraphQlResponseCache
impl RefUnwindSafe for GraphQlResponseCache
impl Send for GraphQlResponseCache
impl Sync for GraphQlResponseCache
impl Unpin for GraphQlResponseCache
impl UnsafeUnpin for GraphQlResponseCache
impl UnwindSafe for GraphQlResponseCache
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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