pub struct ProfileMeCache { /* private fields */ }Expand description
LRU-bounded cache of /api/me responses keyed on TnId.
Uses parking_lot::Mutex (no poisoning) because LruCache::get mutates
recency state.
Implementations§
Source§impl ProfileMeCache
impl ProfileMeCache
pub fn new() -> Self
pub fn with_capacity(capacity: NonZeroUsize) -> Self
Sourcepub fn get(&self, tn_id: TnId) -> Option<Box<str>>
pub fn get(&self, tn_id: TnId) -> Option<Box<str>>
Returns the cached ETag if one is still valid; None otherwise.
Sourcepub fn insert(&self, tn_id: TnId, etag: Box<str>)
pub fn insert(&self, tn_id: TnId, etag: Box<str>)
Inserts a freshly-computed ETag, stamping its expiry from the configured TTL.
Sourcepub fn touch(&self, tn_id: TnId)
pub fn touch(&self, tn_id: TnId)
Refresh an existing entry’s TTL without recomputing its ETag. Called on a 304 fast-path hit so a continuously-polled tenant stays warm. No-op if the entry is already gone.
This makes expiry sliding: a steady poll stream keeps an entry alive
indefinitely, so the 30s TTL no longer bounds staleness for a write path
that forgets to call invalidate. That is acceptable — explicit
invalidate is the real freshness mechanism; the TTL is only a backstop
for a genuinely idle entry.
Sourcepub fn invalidate(&self, tn_id: TnId)
pub fn invalidate(&self, tn_id: TnId)
Drops the cached entry for tn_id. Call immediately after any write that
can change what /api/me returns (profile fields, signing keys).
Trait Implementations§
Source§impl Debug for ProfileMeCache
impl Debug for ProfileMeCache
Auto Trait Implementations§
impl !RefUnwindSafe for ProfileMeCache
impl !UnwindSafe for ProfileMeCache
impl Freeze for ProfileMeCache
impl Send for ProfileMeCache
impl Sync for ProfileMeCache
impl Unpin for ProfileMeCache
impl UnsafeUnpin for ProfileMeCache
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
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().