Help us shape the future of Go! Take the 2026 Go Developer Survey

cache

package
v1.9.16 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[V any] interface {
	// Get retrieves a value from the cache. If found, returns the value, true,
	// and a nil error. If not found, returns a zero value, false, and a nil
	// error. In the event of an error, returns a zero value, false, and the
	// error. Callers should always inspect the last two return values before
	// trusting the first.
	Get(ctx context.Context, key string) (V, bool, error)
	// Set stores a value in the cache. In the event of an error, the error is
	// returned.
	Set(ctx context.Context, key string, value V) error
}

Cache defines a simple interface for cache operations.

func NewInMemoryCache

func NewInMemoryCache[V any](size int) (Cache[V], error)

NewInMemoryCache returns an in-memory implementation of the Cache interface configured with the specified size (maximum number of entries).

Jump to

Keyboard shortcuts

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