storage

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlgoStorage

type AlgoStorage struct {
	Storage
}

AlgoStorage is a wrapper that delegates actual storage logic to an underlying algorithm implementation.

func New

func New(
	ctx context.Context,
	cfg *config.Config,
	backend repository.Backender,
	shardedMap *sharded.Map[*model.Response],
) (db *AlgoStorage)

New returns a new instance of AlgoStorage, initializing the appropriate cache eviction algorithm according to configuration.

Params:

ctx         - context for cancellation and control
cfg         - cache configuration (eviction algorithm, memory limit, etc.)
shardedMap  - shared sharded map storage for concurrent key/value access

type Storage

type Storage interface {
	// Get attempts to retrieve a cached response for the given request.
	// Returns the response, a releaser for safe concurrent access, and a hit/miss flag.
	Get(req *model.Request) (
		resp *model.Response,
		releaser *sharded.Releaser[*model.Response],
		isHit bool,
	)

	// Set stores a new response in the cache and returns a releaser for managing resource lifetime.
	Set(resp *model.Response) (releaser *sharded.Releaser[*model.Response])

	// Stop dumps itself in FS.
	Stop()
}

Storage is a generic interface for cache storages. It supports typical Get/Set operations with reference management.

Directories

Path Synopsis
lru

Jump to

Keyboard shortcuts

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