Documentation
¶
Index ¶
Constants ¶
View Source
const NeverExpired = 0
View Source
const ShardCount = 32
Variables ¶
View Source
var ( ErrKeyAlreadyExists = errors.New("key already exists") ErrKeyNotExists = errors.New("key doesn't exists") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[K comparable, V any] interface { Set(k K, v V, d time.Duration) Add(k K, v V, d time.Duration) error Replace(k K, v V, d time.Duration) error Get(k K) (V, bool) GetWithExpiration(k K) (V, time.Time, bool) Keys() []K Items() map[K]Item[V] Reset() ItemCount() int DeleteExpired() Delete(k K) DeleteWithoutCallback(k K) }
Cache is the interface that represents common cache functionality.
func New ¶
New creates a new cache with a given cleanup interval and callbacks for eviction and stopping events.
func NewSharded ¶ added in v0.0.3
type OnEvicted ¶
type OnEvicted[K comparable, V any] func(K, V)
type Option ¶
type Option[K comparable, V any] struct { OnEvicted OnEvicted[K, V] OnStopped OnStopped }
Click to show internal directories.
Click to hide internal directories.