cache

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Timeout = time.Minute * 120

Timeout is the duration to keep cached Items around.

Functions

This section is empty.

Types

type Cache

type Cache[T any] struct {
	// contains filtered or unexported fields
}

Cache stores data.

func New

func New[T any](name string) (*Cache[T], error)

New creates and returns a new Cache of the specified type.

func (*Cache[T]) Delete

func (c *Cache[T]) Delete(key string) error

Delete removes the given key from the Cache. It is not an error to delete a key that does not exist, in that case no change is made to the underlying data store.

func (*Cache[T]) Load

func (c *Cache[T]) Load(key string) (*T, error)

Load looks up a value under the given key.

func (*Cache[T]) Purge

func (c *Cache[T]) Purge(all bool) error

Purge removes expired entries from the Cache. If all is true, it removes *all* entries.

func (*Cache[T]) Store

func (c *Cache[T]) Store(key string, val *T) error

Store stores a value under the given key.

Jump to

Keyboard shortcuts

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