pub struct HttpResponseCache { /* private fields */ }Expand description
In-memory (method, url, body_hash) → JSON value cache with TTL.
Cheap to clone (Arc-wrapped internals); each enricher instance keeps
its own clone in its hot path, and the daemon may share instances
across enricher reload cycles when the config has not changed.
Implementations§
Source§impl HttpResponseCache
impl HttpResponseCache
Sourcepub fn new(ttl: Duration) -> Self
pub fn new(ttl: Duration) -> Self
Build a new cache with the given TTL.
A ttl of zero is treated as “disabled” — every lookup returns
CacheOutcome::Miss and inserts are no-ops, so call sites can
always go through the cache without checking cache_ttl > 0.
Sourcepub fn is_disabled(&self) -> bool
pub fn is_disabled(&self) -> bool
Returns true when this cache is “off” (TTL is zero).
Sourcepub fn lookup(&self, key: &CacheKey) -> (CacheOutcome, Option<Value>)
pub fn lookup(&self, key: &CacheKey) -> (CacheOutcome, Option<Value>)
Look up key. Returns the cached value if it is present and
within TTL; expires it lazily otherwise.
Sourcepub fn insert(&self, key: CacheKey, value: Value)
pub fn insert(&self, key: CacheKey, value: Value)
Insert value under key. No-op when the cache is disabled.
Sourcepub fn evict_expired(&self) -> usize
pub fn evict_expired(&self) -> usize
Remove every entry whose stored_at + TTL is in the past. Called periodically by a background sweep when the daemon’s enrichment pipeline has at least one cache configured.
Trait Implementations§
Source§impl Clone for HttpResponseCache
impl Clone for HttpResponseCache
Source§fn clone(&self) -> HttpResponseCache
fn clone(&self) -> HttpResponseCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for HttpResponseCache
impl !UnwindSafe for HttpResponseCache
impl Freeze for HttpResponseCache
impl Send for HttpResponseCache
impl Sync for HttpResponseCache
impl Unpin for HttpResponseCache
impl UnsafeUnpin for HttpResponseCache
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointerSource§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, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
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