Versions in this module Expand all Collapse all v0 v0.2.2 Aug 22, 2026 Changes in this version + var ErrTooLarge = errors.New("lingcache: snapshot too large") type Stats + LoadsDropped uint64 + LoadsExpired uint64 v0.2.1 Aug 22, 2026 Changes in this version + var ErrClosed = errors.New("lingcache: closed") + var ErrCorrupt = errors.New("lingcache: corrupt snapshot") + var ErrInvalidSnapshot = errors.New("lingcache: invalid snapshot") + type Cache struct + func Must[K comparable, V any](opts Options[K, V]) *Cache[K, V] + func New[K comparable, V any](opts Options[K, V]) (*Cache[K, V], error) + func (c *Cache[K, V]) Capacity() int + func (c *Cache[K, V]) Clear() + func (c *Cache[K, V]) Close() + func (c *Cache[K, V]) Delete(key K) bool + func (c *Cache[K, V]) Get(key K) (V, bool) + func (c *Cache[K, V]) Has(key K) bool + func (c *Cache[K, V]) Len() int + func (c *Cache[K, V]) Load(r io.Reader) error + func (c *Cache[K, V]) Peek(key K) (V, bool) + func (c *Cache[K, V]) Range(fn func(key K, value V) bool) + func (c *Cache[K, V]) Save(w io.Writer) error + func (c *Cache[K, V]) Set(key K, value V) + func (c *Cache[K, V]) SetWithTTL(key K, value V, ttl time.Duration) + func (c *Cache[K, V]) Stats() Stats + func (c *Cache[K, V]) Sync() + func (c *Cache[K, V]) TTL(key K) (time.Duration, bool) + type Options struct + Capacity int + Clock func() time.Time + DefaultTTL time.Duration + OnEvict func(key K, value V, reason Reason) + ShardCount int + type Reason uint8 + const ReasonDeleted + const ReasonEvicted + const ReasonExpired + func (r Reason) String() string + type Stats struct + Deletes uint64 + Evictions uint64 + Expirations uint64 + Hits uint64 + LoadsSkipped uint64 + Misses uint64 + Sets uint64 + func (s Stats) HitRatio() float64