cache

package
v0.0.0-...-ec1afac Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCacheMiss = errors.New("cache miss")

Functions

This section is empty.

Types

type Cache

type Cache[T any] interface {
	// Get returns the value for the given key.
	// If the key is not found, ErrCacheMiss is returned.
	Get(key string) (value T, err error)
	// Sets the value for the given key.
	Set(key string, value T)
	// Removes the key from the cache.
	Remove(key string)
	// Returns true if the key is found.
	Contains(key string) bool
	// Returns the number of items in the cache.
	Size() int
	// Removes all items from the cache.
	Clear()
}

func NewInMemoryCache

func NewInMemoryCache[T any](ttl time.Duration) Cache[T]

Jump to

Keyboard shortcuts

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