Version: v0.1.0 Latest Latest

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

Go to latest
Published: Nov 19, 2019 License: MIT Imports: 7 Imported by: 0



Package memory provides in-memory cache that implements cache.Cacher interface.



This section is empty.


This section is empty.


This section is empty.


type Cache

type Cache struct {
	// contains filtered or unexported fields

Cache is an implementation of cache.Cacher using map type with an expiration time for each item.

func NewCache

func NewCache(expiration time.Duration) *Cache

NewCache returns a new Cache with given expiration. If set to 0, each item has no expiration time.

func (*Cache) DeleteMulti

func (c *Cache) DeleteMulti(ctx context.Context, keys []*datastorepb.Key) error

DeleteMulti deletes items for the given keys. The returned error is always nil.

func (*Cache) GetMulti

func (c *Cache) GetMulti(ctx context.Context, keys []*datastorepb.Key) [][]byte

GetMulti returns the values of the given keys as a slice of []byte. If the item has expired, the corresponding index of the return value will be nil.

func (*Cache) SetMulti

func (c *Cache) SetMulti(ctx context.Context, keys []*datastorepb.Key, values [][]byte)

SetMulti sets the given keys and values to items.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL