memory

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultMaxItems        = 1_000
	DefaultTTL             = 10 * time.Minute
	DefaultJanitorInterval = 1 * time.Minute
)

Functions

func Store

func Store[K comparable, V any](_ context.Context, cfg *Config) (cache.Cacher[K, V], error)

Types

type Config

type Config struct {
	MaxItems int           `cfg:"max_items" json:"max_items"`
	TTL      time.Duration `cfg:"ttl"       json:"ttl"`

	JanitorInterval time.Duration `cfg:"janitor_interval" json:"janitor_interval"`
}

type Memory

type Memory[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func (*Memory[K, V]) Delete added in v0.2.3

func (m *Memory[K, V]) Delete(_ context.Context, key K) error

func (*Memory[K, V]) Get

func (m *Memory[K, V]) Get(_ context.Context, key K) (V, bool, error)

func (*Memory[K, V]) Set

func (m *Memory[K, V]) Set(_ context.Context, key K, value V) error

Jump to

Keyboard shortcuts

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