Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TTLCache ¶
type TTLCache struct {
// contains filtered or unexported fields
}
TTLCache is a simple in-memory cache with per-entry TTL expiry. Safe for concurrent use. Background goroutine evicts stale entries every 30s. Call Stop() to shut down the background goroutine.
func NewBounded ¶ added in v0.5.0
NewBounded creates a cache limited by entry count and retained bytes. Values admitted to a bounded cache must implement CacheSizeBytes. The byte charge includes that payload size, the key length, and a fixed per-entry charge for cache bookkeeping. It is an accounting bound, not an RSS bound.
func (*TTLCache) Len ¶ added in v0.5.0
Len reports the entries currently held, expired ones included until the eviction loop sweeps them.
func (*TTLCache) Set ¶
Set stores value under key with the given TTL. It returns false when a bounded cache cannot account for or admit the value.