Documentation
¶
Index ¶
- type Cache
- type Deduplicatordeprecated
- type Evictabledeprecated
- type SizedCache
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 is a key value store with bounded size. If the size is attempted to be exceeded, then an element is removed from the cache before the insertion is done, based on evicting the least recently used value.
func NewCacheWithOnEvict ¶ added in v1.2.10
func NewCacheWithOnEvict[K comparable, V any](size int, onEvict func(K, V)) *Cache[K, V]
NewCacheWithOnEvict creates a new LRU cache with the given size and eviction callback.
func (*Cache[_, _]) PortionFilled ¶ added in v1.2.10
type Deduplicator
deprecated
added in
v1.2.10
type Deduplicator[K comparable, V Evictable[K]] struct { // contains filtered or unexported fields }
Deduplicator is an LRU cache that notifies the objects when they are evicted.
Deprecated: Remove this once the vertex state no longer uses it.
func NewDeduplicator
deprecated
added in
v1.2.10
func NewDeduplicator[K comparable, V Evictable[K]](size int) *Deduplicator[K, V]
Deprecated: Remove this once the vertex state no longer uses it.
func (*Deduplicator[_, V]) Deduplicate ¶ added in v1.2.10
func (d *Deduplicator[_, V]) Deduplicate(value V) V
Deduplicate returns either the provided value, or a previously provided value with the same ID that hasn't yet been evicted
func (*Deduplicator[_, _]) Flush ¶ added in v1.2.10
func (d *Deduplicator[_, _]) Flush()
Flush removes all entries from the cache
type Evictable
deprecated
added in
v1.2.10
type Evictable[K comparable] interface { Key() K Evict() }
Evictable allows the object to be notified when it is evicted
Deprecated: Remove this once the vertex state no longer uses it.
type SizedCache ¶ added in v1.2.10
type SizedCache[K comparable, V any] struct { // contains filtered or unexported fields }
SizedCache is a key value store with bounded size. If the size is attempted to be exceeded, then elements are removed from the cache until the bound is honored, based on evicting the least recently used value.
func NewSizedCache ¶ added in v1.2.10
func NewSizedCache[K comparable, V any](maxSize int, size func(K, V) int) *SizedCache[K, V]
func (*SizedCache[K, V]) Evict ¶ added in v1.2.10
func (c *SizedCache[K, V]) Evict(key K)
func (*SizedCache[K, V]) Flush ¶ added in v1.2.10
func (c *SizedCache[K, V]) Flush()
func (*SizedCache[K, V]) Get ¶ added in v1.2.10
func (c *SizedCache[K, V]) Get(key K) (V, bool)
func (*SizedCache[_, _]) Len ¶ added in v1.2.10
func (c *SizedCache[_, _]) Len() int
func (*SizedCache[_, _]) PortionFilled ¶ added in v1.2.10
func (c *SizedCache[_, _]) PortionFilled() float64
func (*SizedCache[K, V]) Put ¶ added in v1.2.10
func (c *SizedCache[K, V]) Put(key K, value V)