Debian Codegraph @

pkg/twcache/cache.go

raw
1 package twcache
2
3 // Cache defines a generic interface for a key-value storage with type constraints on keys and values.
4 // The keys must be of a type that supports comparison.
5 // Add inserts a new key-value pair, potentially evicting an item if necessary.
6 // Get retrieves a value associated with the given key, returning a boolean to indicate if the key was found.
7 // Purge clears all items from the cache.
8 type Cache[K comparable, V any] interface {
9 Add(key K, value V) (evicted bool)
10 Get(key K) (value V, ok bool)
11 Purge()
12 }