cache

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Key added in v0.5.0

func Key(method string, params ...any) string

Key builds a deterministic cache key from a method name and its parameters.

Parameters are rendered by value: pointers are dereferenced, map entries sorted and unexported fields included, so equal arguments always produce the same key and different arguments never share one. Formatting parameters with %v instead would embed pointer addresses for every nested pointer field — which is how AWS SDK input structs are built — yielding a key that changes on every call and can collide once the allocator reuses an address.

The method name is kept as a readable prefix; the parameters are folded into an FNV-64a suffix. The result is safe to use as a file name.

Types

type DataCache

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

func NewDataCache

func NewDataCache() *DataCache

func (*DataCache) Read

func (c *DataCache) Read(name string, data interface{}) bool

func (*DataCache) WithHandlers

func (c *DataCache) WithHandlers(handlers ...HandlerInterface) *DataCache

func (*DataCache) WithNamespace

func (c *DataCache) WithNamespace(namespace string) *DataCache

func (*DataCache) Write

func (c *DataCache) Write(name string, data interface{}) error

type HandlerInterface

type HandlerInterface interface {
	Type() string
	Read(string, interface{}) bool
	Write(string, interface{}) error
}

type Hashable added in v0.5.0

type Hashable interface {
	Hash() string
}

Hashable lets a type supply its own cache-key fragment instead of being walked structurally. Types whose state lives behind a builder API (unexported fields wrapping an SDK input) should implement it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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