store

package
v1.79.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NotFoundError

type NotFoundError struct {
	Key string
}

NotFoundError is returned when a key is not found in the store.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type Store

type Store[T any] interface {
	// Get returns the value associated with the given key or an error.
	Get(key string) (T, error)
	// Replace replaces the contents of the store with the given map.
	Replace(map[string]T)
}

Store is a generic key value store. Implementations should be safe for concurrent use. It is basically just a map with a lock. Does not yet implement Set so we don't have to worry about this thing growing without bound.

func New

func New[T any]() Store[T]

New returns a new store safe for concurrent use.

Jump to

Keyboard shortcuts

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