Documentation
¶
Overview ¶
Package memory stores and fetches context blobs by content address. Put computes the sha256: ref with contextref.Mint and returns it. Get fetches a blob by that ref. A size budget bounds the store; a Put that would exceed the budget evicts the oldest-inserted blobs first.
Map: store.go = Store, New, Put, Get, and the sentinel errors ErrNoBudget, ErrBudgetExceeded, ErrUnknownRef. Memory holds opaque bytes; it does not parse or validate the content, and it does not know about envelope.Message or any other wire type. Rationale: ../docs/plans/memory.md. Contribution rules: ../AGENTS.md.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoBudget is the sentinel for a non-positive maxBytes passed // to New. ErrNoBudget = errors.New("memory: maxBytes must be positive") // ErrBudgetExceeded is the sentinel for a blob that Put rejects // because it is larger than the store's budget. ErrBudgetExceeded = errors.New("memory: content exceeds store budget") // ErrUnknownRef is the sentinel for a ref that Get does not hold. ErrUnknownRef = errors.New("memory: unknown ref") )
Sentinel errors for Store operations; test with errors.Is.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds content-addressed blobs under a fixed byte budget. Mutex-guarded, safe for concurrent use. The zero value is not usable; create a Store with New. A Put that would exceed the budget evicts the oldest-inserted blobs, in insertion order, until the new blob fits.
func (*Store) Get ¶
Get returns a copy of the blob stored under ref. An unknown ref wraps ErrUnknownRef. Get does not change insertion order.
func (*Store) Put ¶
Put computes ref as contextref.Mint(content) and stores content under it. A content whose length exceeds the store's budget wraps ErrBudgetExceeded and stores nothing. A content that fits evicts the oldest-inserted blobs, in insertion order, until the new blob fits within the budget, then stores it. Putting a content whose ref already exists overwrites the stored bytes and refreshes its insertion order to most-recent.