Documentation
¶
Overview ¶
Package memory is the default in-process store: sharded, byte-weighted S3-FIFO (ADR-6). The design is in docs/05-storage-interface-spec.md §5.
This package imports only the standard library (NFR-6).
Index ¶
- Constants
- type Config
- type Store
- func (s *Store) Bytes() int64
- func (s *Store) Close() error
- func (s *Store) Delete(_ context.Context, k store.Key) error
- func (s *Store) Get(_ context.Context, k store.Key) (*store.Entry, error)
- func (s *Store) Info() store.Info
- func (s *Store) MaxObjectBytes() int64
- func (s *Store) NewestEpoch(_ context.Context, tags []store.Tag, since time.Time) (store.Epoch, bool, error)
- func (s *Store) Set(_ context.Context, k store.Key, e *store.Entry) error
- func (s *Store) SetEpoch(_ context.Context, t store.Tag, ep store.Epoch) error
Constants ¶
const MaxEpochSlots = 1 << 26
MaxEpochSlots bounds Config.EpochSlots: 2^26 cells is 256 MiB per plane.
const MaxShards = 1 << 16
MaxShards bounds Config.Shards, so a mistyped count fails New instead of exhausting memory (NFR-2).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
MaxBytes int64 // 0: 256 MiB
Shards int // 0: 16; a power of two, at most MaxShards
MaxRetention time.Duration // 0: 24h; caps every record's lifetime (E-11)
MaxHardEpochs int // 0: 10000 (E-6)
EpochSlots int // 0: 1 << 19; a power of two, at most MaxEpochSlots (E-7)
// OnEvict, when set, receives per-Set eviction counts by queue: "small",
// "main" or "expired". It runs after the shard lock is released.
OnEvict func(queue string, n int)
}
Config sizes a Store (05 §5.1).
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the in-process store. It implements store.Store and store.Sizer.
func New ¶
New returns an empty Store sized by cfg, or an error for a negative setting or a shard or slot count that is not a power of two within its bound.
func (*Store) MaxObjectBytes ¶
MaxObjectBytes returns the largest record the store admits: the small queue's share of one shard, 10% (05 §5.1).
func (*Store) NewestEpoch ¶
func (s *Store) NewestEpoch(_ context.Context, tags []store.Tag, since time.Time) (store.Epoch, bool, error)
NewestEpoch returns the most severe, then latest, epoch among tags at or after since (E-3). Soft and invalid times may be rounded up to the next whole second after the store was built (E-7).