store

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const GoCacheType = "go-cache"
View Source
const RedisType = "redis"

Variables

View Source
var (
	ErrValueNotFound = errors.New("value not found")
)

Functions

This section is empty.

Types

type GoCacheClientInterface

type GoCacheClientInterface interface {
	Get(k string) (interface{}, bool)
	GetWithExpiration(k string) (interface{}, time.Time, bool)
	Set(k string, x interface{}, d time.Duration)
	Delete(k string)
	Add(k string, x interface{}, d time.Duration) error
	Flush()
}

GoCacheClientInterface represents a github.com/patrickmn/go-cache client

type GoCacheStore

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

func NewGoCache

func NewGoCache(client GoCacheClientInterface, options *Options) *GoCacheStore

func (*GoCacheStore) Clear

func (s *GoCacheStore) Clear() error

func (*GoCacheStore) Delete

func (s *GoCacheStore) Delete(key string) error

func (*GoCacheStore) Get

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

func (*GoCacheStore) GetType

func (g *GoCacheStore) GetType() string

func (*GoCacheStore) GetWithTTL

func (s *GoCacheStore) GetWithTTL(key string) (interface{}, time.Duration, error)

func (*GoCacheStore) Set

func (s *GoCacheStore) Set(key string, value interface{}, expiration time.Duration) error

func (*GoCacheStore) SetNX added in v1.9.1

func (s *GoCacheStore) SetNX(key string, value interface{}, expiration time.Duration) bool

type Options

type Options struct {
	Expiration time.Duration
}

type RedisClientInterface

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

type RedisStore

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

func NewRedis

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

func (*RedisStore) Clear

func (s *RedisStore) Clear() error

func (*RedisStore) Delete

func (s *RedisStore) Delete(key string) error

func (*RedisStore) Get

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

func (*RedisStore) GetType

func (s *RedisStore) GetType() string

func (*RedisStore) GetWithTTL

func (s *RedisStore) GetWithTTL(key string) (interface{}, time.Duration, error)

func (*RedisStore) Set

func (s *RedisStore) Set(key string, val interface{}, expiration time.Duration) error

func (*RedisStore) SetNX added in v1.9.1

func (s *RedisStore) SetNX(key string, value interface{}, expiration time.Duration) bool

type StoreInterface

type StoreInterface interface {
	Get(key string) (interface{}, error)
	GetWithTTL(key string) (interface{}, time.Duration, error)
	Set(key string, value interface{}, expiration time.Duration) error
	Delete(key string) error
	Clear() error
	GetType() string
	SetNX(key string, value interface{}, expiration time.Duration) bool
}

Jump to

Keyboard shortcuts

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