cache

package
v0.90.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: AGPL-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 ModuleCache

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

ModuleCache manages compiled WASM module caching.

func NewModuleCache

func NewModuleCache(capacity int, logger *zap.Logger) *ModuleCache

NewModuleCache creates a new ModuleCache.

func (*ModuleCache) Capacity

func (c *ModuleCache) Capacity() int

Capacity returns the maximum cache capacity.

func (*ModuleCache) Clear

func (c *ModuleCache) Clear(ctx context.Context)

Clear removes all modules from the cache and closes them.

func (*ModuleCache) Delete

func (c *ModuleCache) Delete(ctx context.Context, wasmCID string)

Delete removes a module from the cache and closes it.

func (*ModuleCache) Get

func (c *ModuleCache) Get(wasmCID string) (wazero.CompiledModule, bool)

Get retrieves a compiled module from the cache.

func (*ModuleCache) GetOrCompute

func (c *ModuleCache) GetOrCompute(wasmCID string, compute func() (wazero.CompiledModule, error)) (wazero.CompiledModule, error)

GetOrCompute retrieves a module from cache or computes it if not present. The compute function is called with the lock released to avoid blocking.

func (*ModuleCache) GetStats

func (c *ModuleCache) GetStats() (size int, capacity int)

GetStats returns cache statistics.

func (*ModuleCache) Has

func (c *ModuleCache) Has(wasmCID string) bool

Has checks if a module exists in the cache.

func (*ModuleCache) Set

func (c *ModuleCache) Set(wasmCID string, module wazero.CompiledModule)

Set stores a compiled module in the cache. If the cache is full, it evicts the oldest module.

func (*ModuleCache) Size

func (c *ModuleCache) Size() int

Size returns the current number of cached modules.

Jump to

Keyboard shortcuts

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