Documentation
¶
Overview ¶
Package cache implements an in-memory, LRU cache, with preemptive update feature.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrValidation = errors.New("invalid")
)
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[K comparable, T any] struct { // contains filtered or unexported fields }
type Config ¶
type Config[K comparable, T any] struct { // LRUCacheSize is the number of keys to be maintained in the cache LRUCacheSize uint // QLength is the length of update and delete queue QLength uint // CacheAge is for how long the cache would be maintained, apart from the LRU eviction // It's maintained to not maintain stale data if/when keys are not evicted based on LRU CacheAge time.Duration // Threshold is the duration prior to expiry, when the key is considered eligible to be updated Threshold time.Duration DisableCache bool // ServeStale will not return error if the cache has expired. It will return the stale // value, and trigger an update as well. This is useful for usecases where it's ok // to serve stale values and data consistency is not of paramount importance ServeStale bool // UpdaterTimeout is the context time out for when the updater function is called UpdaterTimeout time.Duration Updater updater[K, T] // ErrWatcher is called when there's any error when trying to update cache ErrWatcher ErrOnUpdate }
func (*Config[K, T]) SanitizeValidate ¶
type ErrOnUpdate ¶
type ErrOnUpdate func(err error)
type Tuple ¶
type Tuple[K comparable, T any] struct { Key K Value T }
Click to show internal directories.
Click to hide internal directories.