stores

package
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BLPop

func BLPop(key string, val any) error

func BLPopString

func BLPopString(key string) (string, error)

func BRPop

func BRPop(key string, val any) error

func BRPopString

func BRPopString(key string) (string, error)

func Decr added in v2.0.3

func Decr(key string) (int64, error)

func Del

func Del(keys ...string) (int64, error)

func Exists

func Exists(keys ...string) bool

func Expire

func Expire(key string, expiration time.Duration) bool

func FlushAll

func FlushAll() error

func FlushAllAsync

func FlushAllAsync() error

func FlushDB

func FlushDB() error

func FlushDBAsync

func FlushDBAsync() error

func Get

func Get(key string, val any) error

func GetInt

func GetInt(key string) int

func GetKey added in v2.0.3

func GetKey(key string) string

func GetProto added in v2.0.3

func GetProto(key string, val proto.Message) error

func GetString

func GetString(key string) string

func HDel

func HDel(key string, fields ...string) error

func HDelAll

func HDelAll(key string)

func HExists

func HExists(key, field string) bool

func HGet

func HGet(key, field string, val any) error

func HGetAll

func HGetAll(key string) (map[string]string, error)

func HKeys

func HKeys(key string) ([]string, error)

func HSet

func HSet(key, field string, val any) error

func Incr added in v2.0.3

func Incr(key string) (int64, error)

func InitStoreKeeper

func InitStoreKeeper(cfg config.StoresConf)

func IsRedisNull

func IsRedisNull(err error) bool

func LLen

func LLen(key string) int64

func LPop

func LPop(key string, val any) error

func LPush

func LPush(key string, values ...any) error

func Lock added in v2.0.3

func Lock(key string) (*redsync.Mutex, context.Context, error)

func RPop

func RPop(key string, val any) error

func RPush

func RPush(key string, values ...any) error

func Set

func Set(key string, value any, expire time.Duration) error

func SetNx

func SetNx(key string, value any, expire time.Duration) error

func SetProto added in v2.0.3

func SetProto(key string, value proto.Message, expire time.Duration) error

func SetProtoNx added in v2.0.3

func SetProtoNx(key string, value proto.Message, expire time.Duration) error

func TxPipeline added in v2.0.3

func TxPipeline() redis.Pipeliner

func Unlock added in v2.0.3

func Unlock(mutex *redsync.Mutex, ctx context.Context) error

func ZAdd

func ZAdd(key string, members ...*redis.Z) error

func ZCard

func ZCard(key string) int64

func ZIncrBy

func ZIncrBy(key string, increment float64, member string) (float64, error)

func ZRangeWithScores

func ZRangeWithScores(key string, start, stop int64) ([]redis.Z, error)

func ZRem

func ZRem(key string, members ...any) error

func ZRevRangeWithScores

func ZRevRangeWithScores(key string, start, stop int64) ([]redis.Z, error)

func ZRevRank

func ZRevRank(key, member string) (int64, error)

func ZScore

func ZScore(key, member string) float64

Types

type StoreKeeper

type StoreKeeper interface {
	Set(key string, value any, expire time.Duration) error
	SetNx(key string, value any, expire time.Duration) error //set if not exist
	SetProto(key string, value proto.Message, expire time.Duration) error
	SetProtoNx(key string, value proto.Message, expire time.Duration) error
	Get(key string, val any) error
	GetInt(key string) int
	GetString(key string) string
	GetProto(key string, val proto.Message) error
	Del(keys ...string) (int64, error)
	Exists(keys ...string) bool
	HSet(key, field string, val any) error
	HGet(key, field string, val any) error
	HGetAll(key string) (map[string]string, error)
	HDel(key string, fields ...string) error
	HDelAll(key string)
	HExists(key, field string) bool
	Expire(key string, expiration time.Duration) bool
	HKeys(key string) ([]string, error)
	ZAdd(key string, members ...*redis.Z) error
	ZRangeWithScores(key string, start, stop int64) ([]redis.Z, error)
	ZRevRangeWithScores(key string, start, stop int64) ([]redis.Z, error)
	ZRevRank(key, member string) (int64, error)
	ZScore(key, member string) float64
	ZIncrBy(key string, increment float64, member string) (float64, error)
	ZRem(key string, members ...any) error
	ZCard(key string) int64
	LPush(key string, values ...any) error
	RPush(key string, values ...any) error
	LPop(key string, val any) error
	RPop(key string, val any) error
	BLPop(key string, val any) error
	BRPop(key string, val any) error
	BLPopString(key string) (string, error)
	BRPopString(key string) (string, error)
	Incr(key string) (int64, error)
	Decr(key string) (int64, error)
	LLen(key string) int64
	IsRedisNull(err error) bool
	FlushDB() error
	FlushDBAsync() error
	FlushAll() error
	FlushAllAsync() error
	Lock(key string) (*redsync.Mutex, context.Context, error)
	Unlock(mutex *redsync.Mutex, ctx context.Context) error
	TxPipeline() redis.Pipeliner
	GetKey(key string) string
}

StoreKeeper stores interface

type StoreRedis

type StoreRedis struct {
	Endpoints   []string
	Password    string
	DB          int
	DialTimeout time.Duration
	Client      *redis.Client
	Prefix      string
	// contains filtered or unexported fields
}

func NewStoreRedis

func NewStoreRedis(opts ...StoreRedisOption) *StoreRedis

func (*StoreRedis) BLPop

func (s *StoreRedis) BLPop(key string, val any) error

func (*StoreRedis) BLPopString

func (s *StoreRedis) BLPopString(key string) (string, error)

func (*StoreRedis) BRPop

func (s *StoreRedis) BRPop(key string, val any) error

func (*StoreRedis) BRPopString

func (s *StoreRedis) BRPopString(key string) (string, error)

func (*StoreRedis) Decr added in v2.0.3

func (s *StoreRedis) Decr(key string) (int64, error)

func (*StoreRedis) Del

func (s *StoreRedis) Del(keys ...string) (int64, error)

func (*StoreRedis) Exists

func (s *StoreRedis) Exists(keys ...string) bool

func (*StoreRedis) Expire

func (s *StoreRedis) Expire(key string, expiration time.Duration) bool

func (*StoreRedis) FlushAll

func (s *StoreRedis) FlushAll() error

func (*StoreRedis) FlushAllAsync

func (s *StoreRedis) FlushAllAsync() error

func (*StoreRedis) FlushDB

func (s *StoreRedis) FlushDB() error

func (*StoreRedis) FlushDBAsync

func (s *StoreRedis) FlushDBAsync() error

func (*StoreRedis) Get

func (s *StoreRedis) Get(key string, val any) error

func (*StoreRedis) GetInt

func (s *StoreRedis) GetInt(key string) int

func (*StoreRedis) GetKey

func (s *StoreRedis) GetKey(key string) string

func (*StoreRedis) GetKeys

func (s *StoreRedis) GetKeys(keys []string) []string

func (*StoreRedis) GetProto added in v2.0.3

func (s *StoreRedis) GetProto(key string, val proto.Message) error

func (*StoreRedis) GetString

func (s *StoreRedis) GetString(key string) string

func (*StoreRedis) GetValues

func (s *StoreRedis) GetValues(values []any) []any

func (*StoreRedis) HDel

func (s *StoreRedis) HDel(key string, fields ...string) error

func (*StoreRedis) HDelAll

func (s *StoreRedis) HDelAll(key string)

func (*StoreRedis) HExists

func (s *StoreRedis) HExists(key, field string) bool

func (*StoreRedis) HGet

func (s *StoreRedis) HGet(key, field string, val any) error

func (*StoreRedis) HGetAll

func (s *StoreRedis) HGetAll(key string) (map[string]string, error)

func (*StoreRedis) HKeys

func (s *StoreRedis) HKeys(key string) ([]string, error)

func (*StoreRedis) HSet

func (s *StoreRedis) HSet(key, field string, val any) error

func (*StoreRedis) Incr added in v2.0.3

func (s *StoreRedis) Incr(key string) (int64, error)

func (*StoreRedis) IsRedisNull

func (s *StoreRedis) IsRedisNull(err error) bool

func (*StoreRedis) LLen

func (s *StoreRedis) LLen(key string) int64

func (*StoreRedis) LPop

func (s *StoreRedis) LPop(key string, val any) error

func (*StoreRedis) LPush

func (s *StoreRedis) LPush(key string, values ...any) error

func (*StoreRedis) Lock added in v2.0.3

func (s *StoreRedis) Lock(key string) (*redsync.Mutex, context.Context, error)

func (*StoreRedis) RPop

func (s *StoreRedis) RPop(key string, val any) error

func (*StoreRedis) RPush

func (s *StoreRedis) RPush(key string, values ...any) error

func (*StoreRedis) Set

func (s *StoreRedis) Set(key string, value any, expire time.Duration) error

func (*StoreRedis) SetNx

func (s *StoreRedis) SetNx(key string, value any, expire time.Duration) error

func (*StoreRedis) SetProto added in v2.0.3

func (s *StoreRedis) SetProto(key string, value proto.Message, expire time.Duration) error

func (*StoreRedis) SetProtoNx added in v2.0.3

func (s *StoreRedis) SetProtoNx(key string, value proto.Message, expire time.Duration) error

func (*StoreRedis) TxPipeline added in v2.0.3

func (s *StoreRedis) TxPipeline() redis.Pipeliner

func (*StoreRedis) Unlock added in v2.0.3

func (s *StoreRedis) Unlock(mutex *redsync.Mutex, ctx context.Context) error

func (*StoreRedis) ZAdd

func (s *StoreRedis) ZAdd(key string, members ...*redis.Z) error

func (*StoreRedis) ZCard

func (s *StoreRedis) ZCard(key string) int64

func (*StoreRedis) ZIncrBy

func (s *StoreRedis) ZIncrBy(key string, increment float64, member string) (float64, error)

func (*StoreRedis) ZRangeWithScores

func (s *StoreRedis) ZRangeWithScores(key string, start, stop int64) ([]redis.Z, error)

func (*StoreRedis) ZRem

func (s *StoreRedis) ZRem(key string, members ...any) error

func (*StoreRedis) ZRevRangeWithScores

func (s *StoreRedis) ZRevRangeWithScores(key string, start, stop int64) ([]redis.Z, error)

func (*StoreRedis) ZRevRank

func (s *StoreRedis) ZRevRank(key, member string) (int64, error)

func (*StoreRedis) ZScore

func (s *StoreRedis) ZScore(key, member string) float64

type StoreRedisOption

type StoreRedisOption func(s *StoreRedis)

func WithRedisDB

func WithRedisDB(DB int) StoreRedisOption

func WithRedisDialTimeout

func WithRedisDialTimeout(timeout time.Duration) StoreRedisOption

func WithRedisEndpoints

func WithRedisEndpoints(endpoints []string) StoreRedisOption

func WithRedisPassword

func WithRedisPassword(password string) StoreRedisOption

func WithRedisPrefix

func WithRedisPrefix(prefix string) StoreRedisOption

Jump to

Keyboard shortcuts

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