Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dump ¶
type Dump struct {
// contains filtered or unexported fields
}
Dump implements persistence with versioned directories.
type Refresh ¶
type Refresh struct {
// contains filtered or unexported fields
}
Refresh is responsible for background refreshing of cache entries. It periodically samples random shards and randomly selects "cold" entries (from the end of each shard's Storage list) to refreshItem if necessary. Communication: provider->consumer (MPSC).
func NewRefresher ¶
NewRefresher constructs a Refresh.
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(*model.Entry) (entry *model.VersionPointer, ok bool)
// Set stores a new response in the cache and returns a releaser for managing resource lifetime.
// 1. You definitely cannot use 'request' after use in Set due to it can be removed, you will receive a cache entry on hit!
Set(request *model.VersionPointer) (entry *model.VersionPointer)
// Remove is removes one element.
Remove(*model.VersionPointer) (freedBytes int64, isHit bool)
// Clear is removes all cache entries from the storage.
Clear()
// Stat returns bytes usage and num of items in storage.
Stat() (bytes int64, length int64)
// Len - return stored value (refreshes every 100ms).
Len() int64
// Mem - return stored value (refreshes every 100ms).
Mem() int64
// RealMem - calculates and return value.
RealMem() int64
// Rand returns a random elem from the map.
Rand() (entry *model.VersionPointer, ok bool)
WalkShards(fn func(key uint64, shard *sharded.Shard[*model.VersionPointer]))
}
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.