cache

package
v0.0.0-...-2502259 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: Apache-2.0 Imports: 8 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 interface {
	// Get gets the value of the given key.
	// If the key does not exist, the returned string will be empty ("").
	Get(ctx context.Context, key string) (string, error)
	// SetIfNotExists set key to hold string value if key does not exist (returning true).
	// If key exists, no operation is performed and false is returned as a result.
	// An expiration for the key has to be set. Zero expiration means the key is there forever.
	SetIfNotExists(
		ctx context.Context, key string, value string, expiration time.Duration,
	) (bool, error)
}

A Cache exposes functions from an in-memory store

func New

func New(
	ctx context.Context, conf *config.Values, logger logging.Logger,
) (Cache, error)

New creates a new cache instance

func NewMiniredis

func NewMiniredis() (*miniredis.Miniredis, Cache)

NewMiniredis returns a miniredis and Cache instance for test purposes

func NewTest

func NewTest() Cache

NewTest returns a Cache instance over miniredis

Jump to

Keyboard shortcuts

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