Documentation ¶
Overview ¶
Package cache implements an inmemory cache for any object.
Although exported, this package is non intended for general consumption. It is a shared dependency between multiple exposure notifications projects. We cannot guarantee that there won't be breaking changes in the future.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidDuration = errors.New("expireAfter duration cannot be negative")
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[T any] struct { // contains filtered or unexported fields }
func (*Cache[T]) Clear ¶ added in v0.26.0
func (c *Cache[T]) Clear()
Clear removes all items from the cache, regardless of their expiration.
func (*Cache[T]) Lookup ¶
Lookup checks the cache for a non-expired object by the supplied key name. The bool return informs the caller if there was a cache hit or not. A return of nil, true means that nil is in the cache. Where nil, false indicates a cache miss or that the value is expired and should be refreshed.
func (*Cache[T]) Set ¶
Set saves the current value of an object in the cache, with the supplied durintion until the object expires.