timedcache

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL