Documentation
¶
Index ¶
- type ModuleCache
- func (c *ModuleCache) Capacity() int
- func (c *ModuleCache) Clear(ctx context.Context)
- func (c *ModuleCache) Delete(ctx context.Context, wasmCID string)
- func (c *ModuleCache) Get(wasmCID string) (wazero.CompiledModule, bool)
- func (c *ModuleCache) GetOrCompute(wasmCID string, compute func() (wazero.CompiledModule, error)) (wazero.CompiledModule, error)
- func (c *ModuleCache) GetStats() (size int, capacity int)
- func (c *ModuleCache) Has(wasmCID string) bool
- func (c *ModuleCache) Set(wasmCID string, module wazero.CompiledModule)
- func (c *ModuleCache) Size() int
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.