Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dump ¶
type Dump struct {
// contains filtered or unexported fields
}
type Evict ¶
type Evict struct {
// contains filtered or unexported fields
}
func NewEvictor ¶
func (*Evict) Run ¶
func (e *Evict) Run()
Run launches multiple evictor goroutines for concurrent eviction.
func (*Evict) ShouldEvict ¶
ShouldEvict [HOT PATH METHOD] (max stale value = 25ms) checks if current Weight usage has reached or exceeded the threshold.
type EvictionStat ¶
type EvictionStat struct {
// contains filtered or unexported fields
}
EvictionStat carries statistics for each eviction batch.
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).
type Storage ¶
type Storage interface {
// Run starts storage background worker (just logging at now).
Run()
// 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)
// GetRand returns a random elem from the map.
GetRand() (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)
// 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
}
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.