Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidEvictionPolicy = errors.New("invalid eviction policy")
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[T any] struct { // contains filtered or unexported fields }
Cache is a generic cache implementation using a map not designed for raw performance but to be simple to configure
type CacheEvictionPolicy ¶
type CacheEvictionPolicy int
const ( LRU CacheEvictionPolicy = iota LFU )
type CacheInterface ¶
type CacheInterface[T any] interface { // Set adds or updates an item in the cache Set(key string, value T) error // Get retrieves an item from the cache by key, returning the value and a boolean indicating if the value was found Get(key string) (T, bool) // Delete removes an item from the cache by key Delete(key string) // Clear removes all items from the cache Clear() // Sum returns the count of items in the cache Sum() int }
CacheInterface is an interface for the Cache type mostly for mocking purposes
Click to show internal directories.
Click to hide internal directories.