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.
Click to show internal directories.
Click to hide internal directories.