cache

package
v0.0.0-...-b17c1e0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: MIT Imports: 5 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 tries to retrieve an item from cache using the specified key. If the item does not exist, nil is returned.
	// Value is returned by means of a reference argument `typ`
	Get(ctx context.Context, key string, typ interface{}) error
	// Set will add an item to the cache using the key. If an item exists, it is overwritten.
	Set(ctx context.Context, key string, value interface{}) error
}

Cache defines functionality to cache and retrieve items from an underlying store

type Redis

type Redis struct {
	// contains filtered or unexported fields
}

Redis implements storage of objects in Redis, objects are serialised using JSON

func NewRedis

func NewRedis(conn, pwd string, ttl time.Duration) (Redis, error)

NewRedis returns a new instance of redis

func (*Redis) Get

func (c *Redis) Get(ctx context.Context, key string, typ interface{}) error

Get tries to retrieve an item from cache using the specified key. If the item does not exist, nil is returned.

func (*Redis) Set

func (c *Redis) Set(ctx context.Context, key string, value interface{}) error

Set will add an item to the cache using the key. If an item exists, it is overwritten.

Jump to

Keyboard shortcuts

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