store

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BigcacheType represents the storage type as a string value
	BigcacheType = "bigcache"
	// BigcacheTagPattern represents the tag pattern to be used as a key in specified storage
	BigcacheTagPattern = "gocache_tag_%s"
)
View Source
const (
	// MemcacheType represents the storage type as a string value
	MemcacheType = "memcache"
	// MemcacheTagPattern represents the tag pattern to be used as a key in specified storage
	MemcacheTagPattern = "gocache_tag_%s"
)
View Source
const (
	// RedisType represents the storage type as a string value
	RedisType = "redis"
	// RedisTagPattern represents the tag pattern to be used as a key in specified storage
	RedisTagPattern = "gocache_tag_%s"
)
View Source
const (
	// RistrettoType represents the storage type as a string value
	RistrettoType = "ristretto"
	// RistrettoTagPattern represents the tag pattern to be used as a key in specified storage
	RistrettoTagPattern = "gocache_tag_%s"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BigcacheClientInterface

type BigcacheClientInterface interface {
	Get(key string) ([]byte, error)
	Set(key string, entry []byte) error
	Delete(key string) error
	Reset() error
}

BigcacheClientInterface represents a allegro/bigcache client

type BigcacheStore

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

BigcacheStore is a store for Redis

func NewBigcache

func NewBigcache(client BigcacheClientInterface, options *Options) *BigcacheStore

NewBigcache creates a new store to Bigcache instance(s)

func (*BigcacheStore) Clear

func (s *BigcacheStore) Clear() error

Clear resets all data in the store

func (*BigcacheStore) Delete

func (s *BigcacheStore) Delete(key interface{}) error

Delete removes data from Redis for given key identifier

func (*BigcacheStore) Get

func (s *BigcacheStore) Get(key interface{}) (interface{}, error)

Get returns data stored from a given key

func (*BigcacheStore) GetType

func (s *BigcacheStore) GetType() string

GetType returns the store type

func (*BigcacheStore) Invalidate

func (s *BigcacheStore) Invalidate(options InvalidateOptions) error

Invalidate invalidates some cache data in Redis for given options

func (*BigcacheStore) Set

func (s *BigcacheStore) Set(key interface{}, value interface{}, options *Options) error

Set defines data in Redis for given key identifier

type InvalidateOptions

type InvalidateOptions struct {
	// Tags allows to specify associated tags to the current value
	Tags []string
}

InvalidateOptions represents the cache invalidation available options

func (InvalidateOptions) TagsValue

func (o InvalidateOptions) TagsValue() []string

TagsValue returns the tags option value

type MemcacheClientInterface

type MemcacheClientInterface interface {
	Get(key string) (item *memcache.Item, err error)
	Set(item *memcache.Item) error
	Delete(item string) error
	FlushAll() error
}

MemcacheClientInterface represents a bradfitz/gomemcache client

type MemcacheStore

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

MemcacheStore is a store for Memcache

func NewMemcache

func NewMemcache(client MemcacheClientInterface, options *Options) *MemcacheStore

NewMemcache creates a new store to Memcache instance(s)

func (*MemcacheStore) Clear

func (s *MemcacheStore) Clear() error

Clear resets all data in the store

func (*MemcacheStore) Delete

func (s *MemcacheStore) Delete(key interface{}) error

Delete removes data from Memcache for given key identifier

func (*MemcacheStore) Get

func (s *MemcacheStore) Get(key interface{}) (interface{}, error)

Get returns data stored from a given key

func (*MemcacheStore) GetType

func (s *MemcacheStore) GetType() string

GetType returns the store type

func (*MemcacheStore) Invalidate

func (s *MemcacheStore) Invalidate(options InvalidateOptions) error

Invalidate invalidates some cache data in Redis for given options

func (*MemcacheStore) Set

func (s *MemcacheStore) Set(key interface{}, value interface{}, options *Options) error

Set defines data in Memcache for given key identifier

type Options

type Options struct {
	// Cost corresponds to the memory capacity used by the item when setting a value
	// Actually it seems to be used by Ristretto library only
	Cost int64

	// Expiration allows to specify an expiration time when setting a value
	Expiration time.Duration

	// Tags allows to specify associated tags to the current value
	Tags []string
}

Options represents the cache store available options

func (Options) CostValue

func (o Options) CostValue() int64

CostValue returns the allocated memory capacity

func (Options) ExpirationValue

func (o Options) ExpirationValue() time.Duration

ExpirationValue returns the expiration option value

func (Options) TagsValue

func (o Options) TagsValue() []string

TagsValue returns the tags option value

type RedisClientInterface

type RedisClientInterface interface {
	Get(key string) *redis.StringCmd
	Set(key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Del(keys ...string) *redis.IntCmd
	FlushAll() *redis.StatusCmd
}

RedisClientInterface represents a go-redis/redis client

type RedisStore

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

RedisStore is a store for Redis

func NewRedis

func NewRedis(client RedisClientInterface, options *Options) *RedisStore

NewRedis creates a new store to Redis instance(s)

func (*RedisStore) Clear

func (s *RedisStore) Clear() error

Clear resets all data in the store

func (*RedisStore) Delete

func (s *RedisStore) Delete(key interface{}) error

Delete removes data from Redis for given key identifier

func (*RedisStore) Get

func (s *RedisStore) Get(key interface{}) (interface{}, error)

Get returns data stored from a given key

func (*RedisStore) GetType

func (s *RedisStore) GetType() string

GetType returns the store type

func (*RedisStore) Invalidate

func (s *RedisStore) Invalidate(options InvalidateOptions) error

Invalidate invalidates some cache data in Redis for given options

func (*RedisStore) Set

func (s *RedisStore) Set(key interface{}, value interface{}, options *Options) error

Set defines data in Redis for given key identifier

type RistrettoClientInterface

type RistrettoClientInterface interface {
	Get(key interface{}) (interface{}, bool)
	Set(key, value interface{}, cost int64) bool
	Del(key interface{})
	Clear()
}

RistrettoClientInterface represents a dgraph-io/ristretto client

type RistrettoStore

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

RistrettoStore is a store for Ristretto (memory) library

func NewRistretto

func NewRistretto(client RistrettoClientInterface, options *Options) *RistrettoStore

NewRistretto creates a new store to Ristretto (memory) library instance

func (*RistrettoStore) Clear

func (s *RistrettoStore) Clear() error

Clear resets all data in the store

func (*RistrettoStore) Delete

func (s *RistrettoStore) Delete(key interface{}) error

Delete removes data in Ristretto memoey cache for given key identifier

func (*RistrettoStore) Get

func (s *RistrettoStore) Get(key interface{}) (interface{}, error)

Get returns data stored from a given key

func (*RistrettoStore) GetType

func (s *RistrettoStore) GetType() string

GetType returns the store type

func (*RistrettoStore) Invalidate

func (s *RistrettoStore) Invalidate(options InvalidateOptions) error

Invalidate invalidates some cache data in Redis for given options

func (*RistrettoStore) Set

func (s *RistrettoStore) Set(key interface{}, value interface{}, options *Options) error

Set defines data in Ristretto memoey cache for given key identifier

type StoreInterface

type StoreInterface interface {
	Get(key interface{}) (interface{}, error)
	Set(key interface{}, value interface{}, options *Options) error
	Delete(key interface{}) error
	Invalidate(options InvalidateOptions) error
	Clear() error
	GetType() string
}

StoreInterface is the interface for all available stores

Jump to

Keyboard shortcuts

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