Versions in this module Expand all Collapse all v3 v3.0.1 May 9, 2022 Changes in this version + const DefaultTTL + const NoTTL + type Cache struct + func New(opts ...Option[K, V]) *Cache[K, V] + func (c *Cache[K, V]) Delete(key K) + func (c *Cache[K, V]) DeleteAll() + func (c *Cache[K, V]) DeleteExpired() + func (c *Cache[K, V]) Get(key K, opts ...Option[K, V]) *Item[K, V] + func (c *Cache[K, V]) Items() map[K]*Item[K, V] + func (c *Cache[K, V]) Keys() []K + func (c *Cache[K, V]) Len() int + func (c *Cache[K, V]) Metrics() Metrics + func (c *Cache[K, V]) OnEviction(fn func(context.Context, EvictionReason, *Item[K, V])) func() + func (c *Cache[K, V]) OnInsertion(fn func(context.Context, *Item[K, V])) func() + func (c *Cache[K, V]) OnUpdating(fn func(context.Context, *Item[K, V])) func() + func (c *Cache[K, V]) Set(key K, value V, ttl time.Duration) *Item[K, V] + func (c *Cache[K, V]) Start() + func (c *Cache[K, V]) Stop() + func (c *Cache[K, V]) Touch(key K) + type EvictionReason int + const EvictionReasonCapacityReached + const EvictionReasonDeleted + const EvictionReasonExpired + type Item struct + func (item *Item[K, V]) ExpiresAt() time.Time + func (item *Item[K, V]) IsExpired() bool + func (item *Item[K, V]) Key() K + func (item *Item[K, V]) TTL() time.Duration + func (item *Item[K, V]) Value() V + type Loader interface + Load func(c *Cache[K, V], key K) *Item[K, V] + type LoaderFunc func(*Cache[K, V], K) *Item[K, V] + func (l LoaderFunc[K, V]) Load(c *Cache[K, V], key K) *Item[K, V] + type Metrics struct + Evictions uint64 + Hits uint64 + Insertions uint64 + Misses uint64 + type Option interface + func WithCapacity(c uint64) Option[K, V] + func WithDisableTouchOnHit() Option[K, V] + func WithLoader(l Loader[K, V]) Option[K, V] + func WithTTL(ttl time.Duration) Option[K, V] + type SuppressedLoader struct + func (l *SuppressedLoader[K, V]) Load(c *Cache[K, V], key K) *Item[K, V] Other modules containing this package github.com/dimcz/ttlcache