lru

package
v0.16.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultWasmCacheSize = 1024

	DefaultWasmCacheDir = "wasmcache"
)

Functions

This section is empty.

Types

type WasmLDBCache

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

func NewWasmCache

func NewWasmCache(size int) (*WasmLDBCache, error)

func NewWasmLDBCache

func NewWasmLDBCache(size int) (*WasmLDBCache, error)

func WasmCache

func WasmCache() *WasmLDBCache

func (*WasmLDBCache) Add

func (w *WasmLDBCache) Add(key common.Address, value *WasmModule) bool

Add adds a value to the cache. Returns true if an eviction occurred.

func (*WasmLDBCache) Contains

func (w *WasmLDBCache) Contains(key common.Address) bool

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

func (*WasmLDBCache) ContainsOrAdd

func (w *WasmLDBCache) ContainsOrAdd(key common.Address, value *WasmModule) (ok, evict bool)

ContainsOrAdd 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 found and whether an eviction occurred.

func (*WasmLDBCache) Get

func (w *WasmLDBCache) Get(key common.Address) (*WasmModule, bool)

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

func (*WasmLDBCache) Keys

func (w *WasmLDBCache) Keys() []interface{}

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

func (*WasmLDBCache) Len

func (w *WasmLDBCache) Len() int

Len returns the number of items in the cache.

func (*WasmLDBCache) Peek

func (w *WasmLDBCache) Peek(key common.Address) (*WasmModule, bool)

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

func (*WasmLDBCache) Purge

func (w *WasmLDBCache) Purge()

Purge is used to completely clear the cache

func (*WasmLDBCache) Remove

func (w *WasmLDBCache) Remove(key common.Address)

Remove removes the provided key from the cache.

func (*WasmLDBCache) RemoveOldest

func (w *WasmLDBCache) RemoveOldest()

RemoveOldest removes the oldest item from the cache.

type WasmModule

type WasmModule struct {
	Module *exec.CompiledModule
}

Jump to

Keyboard shortcuts

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