diskbacked

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PackageProps = packageprops.Props{
	WASMWASI:         packageprops.WASMBlocked,
	WASMJS:           packageprops.WASMBlocked,
	WASMFreestanding: packageprops.WASMBlocked,
}

PackageProps records this package's curated properties (ADR-0080). Seeded by `boxer code analysis golang wasmsurvey props generate`; curate by hand. The same group's `props verify` reconciles it.

Functions

This section is empty.

Types

type PebbleStash

type PebbleStash[K comparable, V any] struct {
	// contains filtered or unexported fields
}

PebbleStash implements StashBackendI using CockroachDB's Pebble.

Capacity is enforced via a soft cap and an atomic item counter. softCap=0 means "unbounded" (disk-limited only); a positive value triggers random-victim eviction inside Add once the counter reaches the cap. Pebble's first-row iterator is used to pick the victim, which is effectively random (LSM ordering is by sorted key bytes, but for a cache of unrelated keys this is a reasonable approximation of uniform).

Per the StashBackendI contract the stash is best-effort: storage and codec errors degrade into misses (GetAndRemove) or dropped writes (Add).

func NewPebbleStash

func NewPebbleStash[K comparable, V any](path string, softCap int, cleanStart bool) (*PebbleStash[K, V], error)

NewPebbleStash opens a disk-backed stash at path.

  • softCap: maximum number of entries before Add starts evicting. Zero disables the bound (disk fills until the OS complains).
  • cleanStart: if true, removes any existing DB at path before opening. When false, the existing entries are counted to seed the in-memory counter — that scan is O(n) in the live entry count and runs once.

func (*PebbleStash[K, V]) Add

func (inst *PebbleStash[K, V]) Add(key K, e caching.StashEntry[V]) (evicted bool)

func (*PebbleStash[K, V]) Cap

func (inst *PebbleStash[K, V]) Cap() int

func (*PebbleStash[K, V]) Clear added in v0.0.12

func (inst *PebbleStash[K, V]) Clear()

Clear removes every entry. Failures leave a partial clear behind (best-effort contract); the counter tracks the deletes that succeeded.

func (*PebbleStash[K, V]) Close

func (inst *PebbleStash[K, V]) Close() error

func (*PebbleStash[K, V]) Delete

func (inst *PebbleStash[K, V]) Delete(key K)

func (*PebbleStash[K, V]) GetAndRemove

func (inst *PebbleStash[K, V]) GetAndRemove(key K) (e caching.StashEntry[V], found bool)

func (*PebbleStash[K, V]) Len

func (inst *PebbleStash[K, V]) Len() int

type PogrebStash

type PogrebStash[K comparable, V any] struct {
	// contains filtered or unexported fields
}

PogrebStash implements StashBackendI using the Pogreb key-value store. It uses CBOR for serialization.

Per the StashBackendI contract the stash is best-effort: storage and codec errors degrade into misses (GetAndRemove) or dropped writes (Add).

func NewPogrebStash

func NewPogrebStash[K comparable, V any](path string, softCap int, cleanStart bool) (*PogrebStash[K, V], error)

NewPogrebStash creates a new disk-backed stash.

path: Directory path for the DB. softCap: Approximate maximum number of items. Set to 0 for "unbounded" (disk limited). cleanStart: If true, deletes the DB directory on startup (cache reset).

func (*PogrebStash[K, V]) Add

func (s *PogrebStash[K, V]) Add(key K, e caching.StashEntry[V]) (evicted bool)

Add inserts a value. If softCap is exceeded by a NEW key, it evicts a random item. Updates to an existing key never evict — they don't change the count, so there is no reason to drop an unrelated entry.

func (*PogrebStash[K, V]) Cap

func (s *PogrebStash[K, V]) Cap() int

func (*PogrebStash[K, V]) Clear added in v0.0.12

func (s *PogrebStash[K, V]) Clear()

Clear removes every entry. Keys are collected before deleting — Pogreb's iterator does not guarantee stability under concurrent modification. Failures leave a partial clear behind (best-effort contract).

func (*PogrebStash[K, V]) Close

func (s *PogrebStash[K, V]) Close() error

Close closes the underlying DB. Essential to release file locks.

func (*PogrebStash[K, V]) Delete

func (s *PogrebStash[K, V]) Delete(key K)

func (*PogrebStash[K, V]) GetAndRemove

func (s *PogrebStash[K, V]) GetAndRemove(key K) (e caching.StashEntry[V], found bool)

GetAndRemove attempts to retrieve a value and remove it from the stash (Promotion).

func (*PogrebStash[K, V]) Len

func (s *PogrebStash[K, V]) Len() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL