cache

package
v1.0.0-alpha.24 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameCrypter    = "crypter"
	NameSigningKey = "signing_key"
)

The names these caches report under; see the metrics package for the series. They are exported because whoever builds a cache names it: cache.MeteredLRU is generic and cannot name itself, and two caches built under the same name sum into one series.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[Key comparable, Value any] interface {
	Add(key Key, value Value) (evicted bool)
	Get(key Key) (value Value, ok bool)
}

Cache is the read-write surface a caller needs from a cache, so a service can take one without taking a dependency on how it evicts or whether it meters.

type MeteredLRU

type MeteredLRU[Key comparable, Value any] struct {
	// contains filtered or unexported fields
}

func NewMeteredLRU

func NewMeteredLRU[Key comparable, Value any](name string, size int, opts ...metrics.Option) (*MeteredLRU[Key, Value], error)

func (MeteredLRU[Key, Value]) Add

func (c MeteredLRU[Key, Value]) Add(key Key, value Value) (evicted bool)

func (MeteredLRU[Key, Value]) Get

func (c MeteredLRU[Key, Value]) Get(key Key) (value Value, ok bool)

Jump to

Keyboard shortcuts

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