pub struct PersonaCache { /* private fields */ }Expand description
Thread-safe persona cache with TTL expiration.
This cache stores UserPersona data keyed by SteamID and automatically
considers entries expired after the configured TTL.
Implementations§
Source§impl PersonaCache
impl PersonaCache
Sourcepub fn new(config: PersonaCacheConfig) -> Self
pub fn new(config: PersonaCacheConfig) -> Self
Create a new persona cache with the given configuration.
Sourcepub fn get(&self, steam_id: &SteamID) -> Option<UserPersona>
pub fn get(&self, steam_id: &SteamID) -> Option<UserPersona>
Get persona from cache if not expired.
Returns None if the entry doesn’t exist or has expired.
Sourcepub fn insert(&self, steam_id: SteamID, data: UserPersona)
pub fn insert(&self, steam_id: SteamID, data: UserPersona)
Insert or update a persona in the cache.
If the cache is at capacity, expired entries are evicted first.
Sourcepub fn get_many(
&self,
steam_ids: &[SteamID],
) -> (Vec<UserPersona>, Vec<SteamID>)
pub fn get_many( &self, steam_ids: &[SteamID], ) -> (Vec<UserPersona>, Vec<SteamID>)
Bulk get - returns found (non-expired) entries and missing SteamIDs.
This is useful for optimizing batch lookups where you want to know which IDs need to be fetched from Steam.
§Returns
A tuple of (found_personas, missing_steam_ids)
Sourcepub fn invalidate(&self, steam_id: &SteamID)
pub fn invalidate(&self, steam_id: &SteamID)
Invalidate a specific entry.
Use this when you know a user’s data has changed and the cache should be refreshed on next access.
Sourcepub fn config(&self) -> &PersonaCacheConfig
pub fn config(&self) -> &PersonaCacheConfig
Get the cache configuration.
Sourcepub fn evict_expired(&self)
pub fn evict_expired(&self)
Evict all expired entries.
This can be called periodically to clean up stale entries.
Trait Implementations§
Source§impl Clone for PersonaCache
impl Clone for PersonaCache
Source§impl Debug for PersonaCache
impl Debug for PersonaCache
Auto Trait Implementations§
impl !Freeze for PersonaCache
impl RefUnwindSafe for PersonaCache
impl Send for PersonaCache
impl Sync for PersonaCache
impl Unpin for PersonaCache
impl UnsafeUnpin for PersonaCache
impl UnwindSafe for PersonaCache
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> 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