Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TimedCache ¶
type TimedCache[T comparable] struct { // contains filtered or unexported fields }
TimedCache is a concurrency-safe timed cache. It stores entries, not key-value pairs.
func New ¶
func New[T comparable](logger *zap.Logger, count bool) *TimedCache[T]
New creates a new timed cache. If count is true, entries will take n RemoveEntry calls to be manually removed from the cache where n is the number of times AddEntry is called with the same entry. Entries will be removed from the cache when the deadline is reached regardless of whether the cache is a counting cache or not.
func (*TimedCache[T]) AddEntry ¶
func (t *TimedCache[T]) AddEntry(entry T, ttl time.Duration)
func (*TimedCache[T]) EntryExists ¶
func (t *TimedCache[T]) EntryExists(entry T) bool
func (*TimedCache[T]) RemoveEntry ¶
func (t *TimedCache[T]) RemoveEntry(entry T)
func (*TimedCache[T]) Stop ¶
func (t *TimedCache[T]) Stop()
Stop kills all goroutines waiting on entry deadlines. Entries are not removed from the cache.
Click to show internal directories.
Click to hide internal directories.