cache

package
v1.5.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCacheMiss = errors.New("cache: key is missing")

Functions

func AddCacheFlagsToCmd added in v0.12.0

func AddCacheFlagsToCmd(cmd *cobra.Command) func() (*Cache, error)

AddCacheFlagsToCmd adds flags which control caching to the specified command

Types

type Cache

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

Cache provides strongly types methods to store and retrieve values from shared cache

func NewCache added in v0.12.0

func NewCache(client CacheClient) *Cache

func (*Cache) GetItem added in v1.4.0

func (c *Cache) GetItem(key string, item interface{}) error

func (*Cache) SetItem added in v1.4.0

func (c *Cache) SetItem(key string, item interface{}, expiration time.Duration, delete bool) error

type CacheClient added in v0.12.0

type CacheClient interface {
	Set(item *Item) error
	Get(key string, obj interface{}) error
	Delete(key string) error
}

func NewRedisCache

func NewRedisCache(client *redis.Client, expiration time.Duration) CacheClient

type InMemoryCache added in v0.9.0

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

func NewInMemoryCache

func NewInMemoryCache(expiration time.Duration) *InMemoryCache

func (*InMemoryCache) Delete added in v0.11.0

func (i *InMemoryCache) Delete(key string) error

func (*InMemoryCache) Flush added in v0.9.0

func (i *InMemoryCache) Flush()

func (*InMemoryCache) Get added in v0.9.0

func (i *InMemoryCache) Get(key string, obj interface{}) error

func (*InMemoryCache) Set added in v0.9.0

func (i *InMemoryCache) Set(item *Item) error

type Item

type Item struct {
	Key    string
	Object interface{}
	// Expiration is the cache expiration time.
	Expiration time.Duration
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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