Documentation
¶
Overview ¶
Package l1 provides a sharded, concurrent in-memory cache with TTL and eviction.
Index ¶
- type EntryMeta
- type EvictionPolicy
- type Options
- type Stats
- type Store
- func (s *Store) Close()
- func (s *Store) Delete(key string)
- func (s *Store) Flush()
- func (s *Store) FlushSchema(prefix string)
- func (s *Store) Get(key string) (any, bool)
- func (s *Store) GetWithMeta(key string) (EntryMeta, bool)
- func (s *Store) Set(key string, value any, ttl time.Duration)
- func (s *Store) Stats() Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EvictionPolicy ¶
type EvictionPolicy int
EvictionPolicy determines which entry is removed when MaxEntries is reached.
const ( LRU EvictionPolicy = iota // Least Recently Used LFU // Least Frequently Used FIFO // First In, First Out )
type Options ¶
type Options struct {
TTL time.Duration
MaxEntries int
Eviction EvictionPolicy
SweepInterval time.Duration
Clock clock.Clock
OnEvict func(key string, value any)
}
Options configures an L1 Store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the sharded in-memory cache.
func (*Store) FlushSchema ¶
FlushSchema removes all entries whose key starts with prefix.
func (*Store) GetWithMeta ¶
GetWithMeta retrieves a value and its metadata.
Click to show internal directories.
Click to hide internal directories.