cache

package
v0.0.0-...-519d24f Latest Latest
Warning

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

Go to latest
Published: May 5, 2020 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidDstType is an error returned when dst type doesn't match with the stored one.
	ErrInvalidDstType = errors.New("datastore: dst has invalid type")
	// ErrInvalidDstLength is an error returned when dst type doesn't match with the stored one.
	ErrInvalidDstLength = errors.New("datastore: key and dst slices have different length")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	SetMulti(ctx context.Context, keys []string, values interface{}) error
	GetMulti(ctx context.Context, keys []string, dst interface{}) error
	DeleteMulti(ctx context.Context, keys []string) error
	Clear(ctx context.Context) error
}

Cache interface for the client to use before accessing the datastore

type ErrCacheKeyNotFound

type ErrCacheKeyNotFound string

ErrCacheKeyNotFound is an error alias

func (ErrCacheKeyNotFound) Error

func (e ErrCacheKeyNotFound) Error() string

type MemoryCache

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

MemoryCache is an example type that implements Cache in a single process environment.

func (*MemoryCache) Clear

func (mc *MemoryCache) Clear(ctx context.Context) error

Clear clears the cache

func (*MemoryCache) DeleteMulti

func (mc *MemoryCache) DeleteMulti(ctx context.Context, keys []string) error

DeleteMulti implements Cache#DeleteMulti

func (*MemoryCache) GetMulti

func (mc *MemoryCache) GetMulti(ctx context.Context, keys []string, dst interface{}) error

GetMulti implements Cache#GetMulti

func (*MemoryCache) SetMulti

func (mc *MemoryCache) SetMulti(ctx context.Context, keys []string, values interface{}) error

SetMulti implements Cache#GetMulti

Jump to

Keyboard shortcuts

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