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 NewCache ¶
func NewCache[K comparable, V any](size int) *Cache[K, V]
NewCache creates a new LRU cache with the given size.
func NewCacheWithOnEvict ¶
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 ¶
type Deduplicator
deprecated
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
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 ¶
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 ¶
func (d *Deduplicator[_, _]) Flush()
Flush removes all entries from the cache
type Evictable
deprecated
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 ¶
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 ¶
func NewSizedCache[K comparable, V any](maxSize int, size func(K, V) int) *SizedCache[K, V]
func (*SizedCache[K, V]) Evict ¶
func (c *SizedCache[K, V]) Evict(key K)
func (*SizedCache[K, V]) Flush ¶
func (c *SizedCache[K, V]) Flush()
func (*SizedCache[K, V]) Get ¶
func (c *SizedCache[K, V]) Get(key K) (V, bool)
func (*SizedCache[_, _]) Len ¶
func (c *SizedCache[_, _]) Len() int
func (*SizedCache[_, _]) PortionFilled ¶
func (c *SizedCache[_, _]) PortionFilled() float64
func (*SizedCache[K, V]) Put ¶
func (c *SizedCache[K, V]) Put(key K, value V)