fifocache

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FIFOShardedCache

type FIFOShardedCache struct {
	// contains filtered or unexported fields
}

FIFOShardedCache implements a First In First Out eviction cache

func NewShardedCache

func NewShardedCache(size int, shards int) (*FIFOShardedCache, error)

NewShardedCache creates a new cache instance

func (*FIFOShardedCache) Clear

func (c *FIFOShardedCache) Clear()

Clear is used to completely clear the cache.

func (*FIFOShardedCache) Close

func (c *FIFOShardedCache) Close() error

Close does nothing for this cacher implementation

func (*FIFOShardedCache) Get

func (c *FIFOShardedCache) Get(key []byte) (value interface{}, ok bool)

Get looks up a key's value from the cache.

func (*FIFOShardedCache) Has

func (c *FIFOShardedCache) Has(key []byte) bool

Has checks if a key is in the cache, without updating the recent-ness or deleting it for being stale.

func (*FIFOShardedCache) HasOrAdd

func (c *FIFOShardedCache) HasOrAdd(key []byte, value interface{}, _ int) (has, added bool)

HasOrAdd checks if a key is in the cache without updating the recent-ness or deleting it for being stale, and if not, adds the value. Returns whether the item existed before and whether it has been added.

func (*FIFOShardedCache) IsInterfaceNil

func (c *FIFOShardedCache) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*FIFOShardedCache) Keys

func (c *FIFOShardedCache) Keys() [][]byte

Keys returns a slice of the keys in the cache, from oldest to newest.

func (*FIFOShardedCache) Len

func (c *FIFOShardedCache) Len() int

Len returns the number of items in the cache.

func (*FIFOShardedCache) MaxSize

func (c *FIFOShardedCache) MaxSize() int

MaxSize returns the maximum number of items which can be stored in cache.

func (*FIFOShardedCache) Peek

func (c *FIFOShardedCache) Peek(key []byte) (value interface{}, ok bool)

Peek returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.

func (*FIFOShardedCache) Put

func (c *FIFOShardedCache) Put(key []byte, value interface{}, _ int) (evicted bool)

Put adds a value to the cache. Returns true if an eviction occurred. the int parameter for size is not used as, for now, fifo sharded cache can not count for its contained data size

func (*FIFOShardedCache) RegisterHandler

func (c *FIFOShardedCache) RegisterHandler(handler func(key []byte, value interface{}), id string)

RegisterHandler registers a new handler to be called when a new data is added

func (*FIFOShardedCache) Remove

func (c *FIFOShardedCache) Remove(key []byte)

Remove removes the provided key from the cache.

func (*FIFOShardedCache) SizeInBytesContained

func (c *FIFOShardedCache) SizeInBytesContained() uint64

SizeInBytesContained returns 0

func (*FIFOShardedCache) UnRegisterHandler

func (c *FIFOShardedCache) UnRegisterHandler(id string)

UnRegisterHandler removes the handler from the list

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL