Documentation ¶
Overview ¶
Package cachedmap provides a CachedMap which functions as a map with a TTL for old entries. So after an entry is "removed" from the map its value is still available for a certain amount of time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachedMap ¶
type CachedMap[Key comparable, T any] interface { Clear() Add(key Key, obj T) Remove(key Key) Keys() []Key Values() []T Get(key Key) (T, bool) GetCmp(cmp func(T) bool) (T, bool) // Close stops the background goroutine that prunes old entries Close() }
func NewCachedMap ¶
func NewCachedMap[Key comparable, T any](oldEntryTTL time.Duration) CachedMap[Key, T]
NewCachedMap creates a new CachedMap with the given oldEntryTTL The old entries will be deleted between oldEntryTTL and 2*oldEntryTTL
Click to show internal directories.
Click to hide internal directories.