storage

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSingleMock added in v1.1.1

func GetSingleMock(i int, path []byte, cfg config.Config) *model.Entry

func GetSingleMockWith added in v1.4.3

func GetSingleMockWith(i int, path []byte, cfg config.Config, brotli bool) *model.Entry

GetSingleMockWith builds a single mock Entry for the given index/path/config. Brotli compression is controlled by the brotli flag.

func LoadMocks added in v0.9.8

func LoadMocks(ctx context.Context, cfg config.Config, storage Storage, num int)

func LoadMocksWith added in v1.4.3

func LoadMocksWith(ctx context.Context, cfg config.Config, storage Storage, num int, brotli bool)

LoadMocksWith generates and stores num mock entries asynchronously.

func StreamEntryPointersConsecutive added in v1.2.0

func StreamEntryPointersConsecutive(ctx context.Context, cfg config.Config, path []byte, num int) <-chan *model.Entry

func StreamEntryPointersConsecutiveWith added in v1.4.3

func StreamEntryPointersConsecutiveWith(ctx context.Context, cfg config.Config, path []byte, num int, brotli bool) <-chan *model.Entry

StreamEntryPointersConsecutiveWith streams num entries (ordered) with given brotli flag.

Types

type DB added in v1.3.0

type DB struct {
	*lru.InMemoryStorage
	// contains filtered or unexported fields
}

DB wraps the LRU storage and supervises worker groups through a Governor.

func New added in v1.4.4

New constructs the storage, wires workers and starts the governor. All transitions are done through the governor (no direct goroutine starts here).

func (*DB) Close added in v1.3.0

func (db *DB) Close() error

Close performs a graceful shutdown: dump (if enabled), stop LRU, then stop the governor.

type Dump

type Dump struct {
	// contains filtered or unexported fields
}

func (*Dump) Dump

func (d *Dump) Dump(ctx context.Context) error

func (*Dump) Load

func (d *Dump) Load(ctx context.Context) error

func (*Dump) LoadVersion added in v1.0.3

func (d *Dump) LoadVersion(ctx context.Context, v string) error

type Dumper

type Dumper interface {
	Dump(ctx context.Context) error
	Load(ctx context.Context) error
	LoadVersion(ctx context.Context, v string) error
}

type Storage

type Storage interface {
	Get(*model.Entry) (entry *model.Entry, hit bool)
	Set(entry *model.Entry) (persisted bool)
	WalkShards(ctx context.Context, fn func(key uint64, shard *sharded.Shard[*model.Entry]))
	Remove(*model.Entry) (freedBytes int64, hit bool)
	Stat() (bytes int64, length int64)
	EvictN(n, shardSample, entriesSample int) (freedBytes, items int64)
	ScanOutdatedN(dst []*model.Entry, shardSample, entrySample int) (out []*model.Entry, found int)
	ShouldEvictSoft() (diffBytes int64, should bool)
	ShouldEvictHard() (diffBytes int64, should bool)
	Clear()
	Close() error
}

Storage is a generic interface for cache storages.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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