Documentation
¶
Overview ¶
Package cache provides owner-serialized caches with deterministic LRU eviction Values are caller-owned immutable snapshots. Costs are logical retained bytes, not process RSS; keys and fixed entry overhead are charged automatically
Index ¶
- Constants
- type Budget
- type Cache
- func (c *Cache[T]) Bytes() int
- func (c *Cache[T]) Clear()
- func (c *Cache[T]) Delete(key string) bool
- func (c *Cache[T]) Entries(now int64) ([]Entry[T], error)
- func (c *Cache[T]) Get(key string, now int64) (T, bool)
- func (c *Cache[T]) Len() int
- func (c *Cache[T]) Peek(key string, now int64) (T, bool)
- func (c *Cache[T]) Put(key string, value T, cost int, expires, now int64) ([]string, error)
- func (c *Cache[T]) Trim(reserved int, now int64) ([]string, error)
- type Entry
- type Persistence
Constants ¶
const MaxBytes = 64 << 20
const MaxEntries = 65536
const MaxTime int64 = 9007199254740991
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Budget ¶
type Budget struct {
// contains filtered or unexported fields
}
Budget bounds aggregate retained data shared by several snapshots
type Cache ¶
type Cache[T any] struct { // contains filtered or unexported fields }
func (*Cache[T]) Clear ¶
func (c *Cache[T]) Clear()
Discard all cache entries and reset byte accounting
type Persistence ¶
type Persistence[T any] struct { // contains filtered or unexported fields }
Persistence explicitly uses a caller-selected private host namespace. No fallback Flush uses bounded atomic batches and managed-state receipt recovery
func NewPersistence ¶
func NewPersistence[T any](backend managedstate.PrivateBackend) (*Persistence[T], error)
Bind cache persistence to an explicitly selected private backend