Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[K comparable, V any] struct { // contains filtered or unexported fields }
Cache consists of an LRU cache and the evicted items from the LRU cache. This data structure makes sure all the cached items can be retrieved either from the LRU cache or the evictedItems map. In spanmetricsprocessor's use case, we need to hold all the items during the current processing step for building the metrics. The evicted items can/should be safely removed once the metrics are built from the current batch of spans.
Important: This implementation is non-thread safe.
func NewCache ¶
func NewCache[K comparable, V any](size int) (*Cache[K, V], error)
NewCache creates a Cache.
func (*Cache[K, V]) Add ¶ added in v0.64.0
Add a value to the cache, returns true if an eviction occurred and updates the "recently used"-ness of the key.
func (*Cache[K, V]) Purge ¶
func (c *Cache[K, V]) Purge()
Purge removes all the items from the LRU cache and evicted items.
func (*Cache[K, V]) RemoveEvictedItems ¶
func (c *Cache[K, V]) RemoveEvictedItems()
RemoveEvictedItems cleans all the evicted items.