store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2019 License: MIT Imports: 6 Imported by: 29

Documentation

Index

Constants

View Source
const (
	BigcacheType = "bigcache"
)
View Source
const (
	MemcacheType = "memcache"
)
View Source
const (
	RedisType = "redis"
)
View Source
const (
	RistrettoType = "ristretto"
)

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
}

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) 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) Set

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

Set defines data in Redis for given key idntifier

type MemcacheClientInterface

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

MemcacheClientInterface represents a bradfitz/gomemcache client

type MemcacheStore

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

MemcacheStore is a store for Redis

func NewMemcache

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

NewMemcache creates a new store to Memcache instance(s)

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) Set

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

Set defines data in Redis for given key idntifier

type MockBigcacheClientInterface

type MockBigcacheClientInterface struct {
	mock.Mock
}

MockBigcacheClientInterface is an autogenerated mock type for the BigcacheClientInterface type

func (*MockBigcacheClientInterface) Get

func (_m *MockBigcacheClientInterface) Get(key string) ([]byte, error)

Get provides a mock function with given fields: key

func (*MockBigcacheClientInterface) Set

func (_m *MockBigcacheClientInterface) Set(key string, entry []byte) error

Set provides a mock function with given fields: key, entry

type MockMemcacheClientInterface

type MockMemcacheClientInterface struct {
	mock.Mock
}

MockMemcacheClientInterface is an autogenerated mock type for the MemcacheClientInterface type

func (*MockMemcacheClientInterface) Get

Get provides a mock function with given fields: key

func (*MockMemcacheClientInterface) Set

Set provides a mock function with given fields: item

type MockRedisClientInterface

type MockRedisClientInterface struct {
	mock.Mock
}

MockRedisClientInterface is an autogenerated mock type for the RedisClientInterface type

func (*MockRedisClientInterface) Get

Get provides a mock function with given fields: key

func (*MockRedisClientInterface) Set

func (_m *MockRedisClientInterface) Set(key string, value interface{}, expiration time.Duration) *redis.StatusCmd

Set provides a mock function with given fields: key, value, expiration

type MockRistrettoClientInterface

type MockRistrettoClientInterface struct {
	mock.Mock
}

MockRistrettoClientInterface is an autogenerated mock type for the RistrettoClientInterface type

func (*MockRistrettoClientInterface) Get

func (_m *MockRistrettoClientInterface) Get(key interface{}) (interface{}, bool)

Get provides a mock function with given fields: key

func (*MockRistrettoClientInterface) Set

func (_m *MockRistrettoClientInterface) Set(key interface{}, value interface{}, cost int64) bool

Set provides a mock function with given fields: key, value, cost

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
}

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

type RedisClientInterface

type RedisClientInterface interface {
	Get(key string) *redis.StringCmd
	Set(key string, value interface{}, expiration time.Duration) *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) 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) Set

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

Set defines data in Redis for given key idntifier

type RistrettoClientInterface

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

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) 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) Set

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

Set defines data in Ristretto memoey cache for given key idntifier

type StoreInterface

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

StoreInterface is the interface for all available stores

Directories

Path Synopsis
bigcache module
freecache module
go_cache module
hazelcast module
memcache module
pegasus module
redis module
rediscluster module
ristretto module
rueidis module

Jump to

Keyboard shortcuts

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