pub struct MemoryPersistedQueryStore { /* private fields */ }async-graphql only.Expand description
Default in-memory store backed by scc::HashMap with a hard-capped entry
count. The previous implementation was unbounded, which let any client
flood the cache with (unique-hash, full-query) pairs and OOM the
process. Use Self::with_max_entries to size the cap; the default is
1024 entries.
When the cap is reached, the store performs a bulk flush rather than LRU
eviction (the underlying scc::HashMap does not expose ordering hooks).
Callers that need finer-grained eviction should wrap their own store
implementing PersistedQueryStore.
Soft cap, not hard: the len() >= cap → clear() → insert() sequence
in PersistedQueryStore::put is not atomic. Concurrent puts each
observe len < cap, all proceed past the check, and each insert lands —
the effective ceiling is cap + concurrent_put_count. The race is
memory-safe (scc takes care of the per-entry locking) and only ever
over-shoots by the number of in-flight puts, which is bounded by your
request concurrency. If you need a hard cap, layer in your own
PersistedQueryStore impl with Mutex<HashMap> semantics.
Implementations§
Source§impl MemoryPersistedQueryStore
impl MemoryPersistedQueryStore
Sourcepub fn new() -> MemoryPersistedQueryStore
pub fn new() -> MemoryPersistedQueryStore
Create a store with the default 1024-entry cap.
Sourcepub fn with_max_entries(max_entries: usize) -> MemoryPersistedQueryStore
pub fn with_max_entries(max_entries: usize) -> MemoryPersistedQueryStore
Create a store that admits at most max_entries cached (hash, query)
pairs before the next insert triggers a full flush.
Trait Implementations§
Source§impl Clone for MemoryPersistedQueryStore
impl Clone for MemoryPersistedQueryStore
Source§fn clone(&self) -> MemoryPersistedQueryStore
fn clone(&self) -> MemoryPersistedQueryStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for MemoryPersistedQueryStore
impl Default for MemoryPersistedQueryStore
Source§fn default() -> MemoryPersistedQueryStore
fn default() -> MemoryPersistedQueryStore
Source§impl PersistedQueryStore for MemoryPersistedQueryStore
impl PersistedQueryStore for MemoryPersistedQueryStore
Auto Trait Implementations§
impl Freeze for MemoryPersistedQueryStore
impl RefUnwindSafe for MemoryPersistedQueryStore
impl Send for MemoryPersistedQueryStore
impl Sync for MemoryPersistedQueryStore
impl Unpin for MemoryPersistedQueryStore
impl UnsafeUnpin for MemoryPersistedQueryStore
impl UnwindSafe for MemoryPersistedQueryStore
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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