Documentation
¶
Index ¶
- Variables
- type Account
- func (a *Account[K]) Available(bytes uint64) bool
- func (a *Account[K]) Close() error
- func (a *Account[K]) Reserve(bytes uint64) (Reservation, bool)
- func (a *Account[K]) Store(key K, data []byte, reservation Reservation) (*Cached[K], error)
- func (a *Account[K]) TakeEvicted() []*Cached[K]
- func (a *Account[K]) Used() uint64
- type Budget
- type Cached
- type Reservation
Constants ¶
This section is empty.
Variables ¶
var ErrReservation = errors.New("buffer does not own a matching live reservation")
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account[K comparable] struct { // contains filtered or unexported fields }
func NewAccount ¶
func NewAccount[K comparable](budget *Budget, limit uint64) *Account[K]
func (*Account[K]) Available ¶
Available includes reclaimable cache, but never output or authentication holdings. Selection can inspect pressure without allocating and rolling back.
func (*Account[K]) Close ¶
Close retires the account's cache after its workers have joined. Independently delivered buffers stay charged and are reported instead of being revoked.
func (*Account[K]) Store ¶
func (a *Account[K]) Store(key K, data []byte, reservation Reservation) (*Cached[K], error)
Store consumes a matching reservation without changing the charged total. Rejecting an invalid handoff leaves the caller's ownership untouched.
func (*Account[K]) TakeEvicted ¶
TakeEvicted transfers pressure-eviction records to the account owner, so index cleanup follows actual evictions instead of scanning live cache entries.
type Budget ¶
type Budget struct {
// contains filtered or unexported fields
}
Budget owns both retained copies and immediately reclaimable cache across receivers. Cache eviction never calls another receiver while holding a lock.
type Cached ¶
type Cached[K comparable] struct { // contains filtered or unexported fields }
type Reservation ¶
type Reservation struct {
// contains filtered or unexported fields
}
Reservation carries the account and exact bytes that can be returned. Value copies share one claim, and an old copy cannot release a transferred claim.
func (Reservation) Bytes ¶
func (r Reservation) Bytes() uint64
func (Reservation) Release ¶
func (r Reservation) Release() bool
func (Reservation) Split ¶
func (r Reservation) Split(bytes uint64) (Reservation, bool)
Split preserves the aggregate admission: canonical data, output delivery, and an admitted attempt may separate only after their total capacity was reserved.
func (Reservation) Transfer ¶
func (r Reservation) Transfer() (Reservation, bool)