Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExpiringCache ¶
type ExpiringCache[KeyType comparable, ValueType any] interface { // Get operates identically to retrieving from a map, returning // the value and/or boolean indicating if the value existed in the map // // Multiple callers can receive the same value simultaneously from Get, // it is the caller's responsibility to ensure they are not modified Get(key KeyType) (value *ValueType, ok bool) // Set operates identically to setting a value in a map, adding an entry // or overriding the existing value for a given key Set(key KeyType, value *ValueType) }
ExpiringCache is a thread-safe "time expiring" cache that automatically removes objects that are not accessed for a configurable delay
It is used in various places where we need to cache data for an unknown amount of time, to prevent memory leaks
From the consumer's perspective, it behaves similarly to a map KeyType is the type of the object that is used as a key ValueType is the type of the object that is stored.
func New ¶
func New[KeyType comparable, ValueType any](expirationDelay time.Duration) ExpiringCache[KeyType, ValueType]
New returns a new ExpiringCache for a given KeyType, ValueType, and expiration delay.
Click to show internal directories.
Click to hide internal directories.