immunitycache

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: GPL-3.0 Imports: 10 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 active immune intents across all chunks.

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, nonce uint64) (numNowTotal, numFutureTotal int)

ImmunizeKeys marks items as immune to eviction for the provided confirmation nonce. The cache-level capacity check is diagnostic only; chunk-level smart-reject decides per-key whether to accept new intents (see immunityChunk.ImmunizeKeys).

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) SetOldestImmuneNonce added in v1.1.1

func (ic *ImmunityCache) SetOldestImmuneNonce(nonce uint64)

SetOldestImmuneNonce deactivates immunity below the provided nonce

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