Documentation
¶
Overview ¶
Package ttlcache provides an experimental passive, fixed-TTL LRU cache. It starts no goroutines. Expired entries are unreadable immediately, but can retain references until a subsequent write, Len, DeleteAll, or disposal.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[K comparable, V any] struct { // contains filtered or unexported fields }
Cache uses jellydator for TTL checks and read recency. The oldest write has the earliest deadline because Get never extends TTL. Keep write order independently so one Set can reclaim one expired slot, regardless of recency.
func New ¶
New creates a cache. Nonpositive capacity means unlimited and nonpositive TTL means no expiration.
func (*Cache[K, V]) DeleteAll ¶
func (c *Cache[K, V]) DeleteAll()
DeleteAll releases all retained entries.
func (*Cache[K, V]) Get ¶
Get returns a live value and promotes its LRU position without renewing TTL.