cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound    = errors.New("cache: not found")
	ErrInvalidType = errors.New("cache: not expected type")
)

Functions

func Bytes

func Bytes(value interface{}) ([]byte, error)

func MakeHashSlotKey

func MakeHashSlotKey(hashTag, id, environmentNamespace string) string

MakeHashSlotKey creates a key to ensure that multiple keys are allocated in the same hash slot. https://redis.io/topics/cluster-spec#keys-hash-tags

func MakeKey

func MakeKey(kind, id, environmentNamespace string) string

func MakeKeyPrefix

func MakeKeyPrefix(kind, environmentNamespace string) string

Types

type Cache

type Cache interface {
	Getter
	Putter
}

func NewRedisCache

func NewRedisCache(cluster redis.Cluster) Cache

type Deleter

type Deleter interface {
	Delete(key string) error
}

type Getter

type Getter interface {
	Get(key interface{}) (interface{}, error)
}

type Lister

type Lister interface {
	Keys(pattern string, maxSize int) ([]string, error)
}

FIXME: remove after persistent-redis migration

type MultiGetCache

type MultiGetCache interface {
	Cache
	MultiGetter
}

type MultiGetDeleteCache

type MultiGetDeleteCache interface {
	MultiGetCache
	Deleter
}

type MultiGetter

type MultiGetter interface {
	GetMulti(keys interface{}) ([]interface{}, error)
	Scan(cursor, key, count interface{}) (uint64, []string, error)
}

type Putter

type Putter interface {
	Put(key interface{}, value interface{}) error
}

type TTLCache

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

func NewTTLCache

func NewTTLCache(ttl time.Duration, evictionInterval time.Duration) *TTLCache

func (*TTLCache) Destroy

func (c *TTLCache) Destroy()

func (*TTLCache) Get

func (c *TTLCache) Get(key interface{}) (interface{}, error)

func (*TTLCache) Put

func (c *TTLCache) Put(key interface{}, value interface{}) error

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
v3
mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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