Documentation
¶
Overview ¶
Package cache provides a simple cache.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[K comparable, V any] struct { // contains filtered or unexported fields }
Cache is a thread safe key/value map where the entries can expire.
func New ¶
func New[K comparable, V any](lifetime time.Duration) *Cache[K, V]
New creates a new cache where the lifetime is the duration of a valid cache entry, after which the entry is considered expired.
func (*Cache[K, V]) Get ¶
Get returns a copy of of the value V associated with the key, and the status of that value. A status of true indicates the value can be used. A status of false indicates the value is unusable, being either expired or not in the cache.
Click to show internal directories.
Click to hide internal directories.