immunitycache

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: GPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheConfig

type CacheConfig struct {
	Name                        string
	NumChunks                   uint32
	MaxNumItems                 uint32
	MaxNumBytes                 uint32
	NumItemsToPreemptivelyEvict uint32
}

CacheConfig holds cache configuration

func (*CacheConfig) String

func (config *CacheConfig) String() string

String returns a readable representation of the object

func (*CacheConfig) Verify

func (config *CacheConfig) Verify() error

Verify verifies the validity of the configuration

type ImmunityCache

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

ImmunityCache is a cache-like structure

func NewImmunityCache

func NewImmunityCache(config CacheConfig) (*ImmunityCache, error)

NewImmunityCache creates a new cache

func (*ImmunityCache) Clear

func (ic *ImmunityCache) Clear()

Clear clears the map

func (*ImmunityCache) Close

func (ic *ImmunityCache) Close() error

Close does nothing for this cacher implementation

func (*ImmunityCache) Count

func (ic *ImmunityCache) Count() int

Count returns the number of elements within the map

func (*ImmunityCache) CountImmune

func (ic *ImmunityCache) CountImmune() int

CountImmune returns the number of immunized (current or future) elements within the map

func (*ImmunityCache) Diagnose

func (ic *ImmunityCache) Diagnose(_ bool)

Diagnose displays a summary of the internal state of the cache

func (*ImmunityCache) ForEachItem

func (ic *ImmunityCache) ForEachItem(function types.ForEachItem)

ForEachItem iterates over the items in the cache

func (*ImmunityCache) Get

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

Get gets an item (payload) by key

func (*ImmunityCache) Has

func (ic *ImmunityCache) Has(key []byte) bool

Has checks is an item exists

func (*ImmunityCache) HasOrAdd

func (ic *ImmunityCache) HasOrAdd(key []byte, value interface{}, sizeInBytes int) (has, added bool)

HasOrAdd adds an item in the cache

func (*ImmunityCache) ImmunizeKeys

func (ic *ImmunityCache) ImmunizeKeys(keys [][]byte) (numNowTotal, numFutureTotal int)

ImmunizeKeys marks items as immune to eviction

func (*ImmunityCache) IsInterfaceNil

func (ic *ImmunityCache) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ImmunityCache) Keys

func (ic *ImmunityCache) Keys() [][]byte

Keys returns all keys

func (*ImmunityCache) Len

func (ic *ImmunityCache) Len() int

Len is an alias for Count

func (*ImmunityCache) MaxSize

func (ic *ImmunityCache) MaxSize() int

MaxSize returns the capacity of the cache

func (*ImmunityCache) NumBytes

func (ic *ImmunityCache) NumBytes() int

NumBytes estimates the size of the cache, in bytes

func (*ImmunityCache) Peek

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

Peek gets an item

func (*ImmunityCache) Put

func (ic *ImmunityCache) Put(key []byte, value interface{}, sizeInBytes int) (evicted bool)

Put adds an item in the cache

func (*ImmunityCache) RegisterHandler

func (ic *ImmunityCache) RegisterHandler(func(key []byte, value interface{}), string)

RegisterHandler is not implemented

func (*ImmunityCache) Remove

func (ic *ImmunityCache) Remove(key []byte)

Remove removes an item

func (*ImmunityCache) RemoveOldest

func (ic *ImmunityCache) RemoveOldest()

RemoveOldest is not implemented

func (*ImmunityCache) RemoveWithResult

func (ic *ImmunityCache) RemoveWithResult(key []byte) bool

RemoveWithResult removes an item TODO: In the future, add this method to the "storage.Cacher" interface. EN-6739.

func (*ImmunityCache) SizeInBytesContained

func (ic *ImmunityCache) SizeInBytesContained() uint64

SizeInBytesContained returns 0

func (*ImmunityCache) UnRegisterHandler

func (ic *ImmunityCache) UnRegisterHandler(_ 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