cache

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T any](key string, t T) (T, bool)

Get returns a value from the cache. When there is no valid cache item available, the function will return the passed parameter t.

func Init

func Init(mode Mode, lifetime time.Duration, _ Dsn)

Init initializes the caching system. The cache implementation used is chosen by the supplied Mode.

func Invalidate

func Invalidate[T any](key string, t T) bool

Invalidate the cache item with the given key and type. The function returns whether an item has been invalidated or not.

func Update

func Update[T any](key string, value T)

Update adds or updates the given value to the cache with the given key.

Types

type Dsn

type Dsn string

Dsn is the information necessary to connect to a remote server like redis. It is necessary for some cache implementations.

type Mode

type Mode string

Mode specifies what cache implementation should be used

const (
	ModeMemory Mode = "memory"
	ModeRedis  Mode = "redis"
)

Available cache modes

type Provider

type Provider interface {
	Get(key string, t interface{}) (interface{}, bool)
	Update(key string, t reflect.Type, value interface{})
	Invalidate(key string, t reflect.Type) bool
}

Provider specifies the interface that different cache implementations must provide.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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