Documentation
¶
Overview ¶
Package expcache provides an in-memory expiry cache.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[T any] struct { // contains filtered or unexported fields }
Cache is an expiry cache that does not prune out of date elements.
Is thread-safe.
func New ¶
func New[T any](f TimeToLiveFunc) *Cache[T]
Dynamic creates an expiry cache using a functional ttl computed based on the current time.
func (*Cache[T]) Get ¶
Get returns the value and whether the cache considers the value to be usable. The value is not usable if it does not exist, or is past its TTL expiration.
func (*Cache[T]) GetMap ¶
GetMap returns a Maybe for each given key. The Maybe indicates whether the item is considered usable. An item is not usable if no value exists for a given key, or the value for the given key is past its TTL expiration.
type TimeToLiveFunc ¶
TimeToLiveFunc represents the function used by a Cache to determine how long an item should be accessible in the cache.
Often returns a static value, or a value based on time of day, etc.
func TTL ¶
func TTL(duration time.Duration) TimeToLiveFunc
TTL returns a TimeToLiveFunc around a static ttl duration.