redis

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DialerSrv = "srv"
	DialerTcp = "tcp"
)
View Source
const (
	Nil = baseRedis.Nil
)

Variables

This section is empty.

Functions

func GetFullyQualifiedKey

func GetFullyQualifiedKey(appId cfg.AppId, key string) string

func IsRetryableError

func IsRetryableError(err error) bool

func NewBackoffExecutor

func NewBackoffExecutor(logger log.Logger, settings exec.BackoffSettings, name string) exec.Executor

func NewExecutor

func NewExecutor(logger log.Logger, settings exec.BackoffSettings, name string) exec.Executor

func NilChecker

func NilChecker(_ interface{}, err error) exec.ErrorType

func OOMChecker

func OOMChecker(_ interface{}, err error) exec.ErrorType

func RetryableErrorChecker

func RetryableErrorChecker(_ interface{}, err error) exec.ErrorType

Types

type Client

type Client interface {
	Del(ctx context.Context, keys ...string) (int64, error)
	DBSize(ctx context.Context) (int64, error)
	Exists(ctx context.Context, keys ...string) (int64, error)
	Expire(ctx context.Context, key string, ttl time.Duration) (bool, error)
	FlushDB(ctx context.Context) (string, error)
	Get(ctx context.Context, key string) (string, error)
	GetDel(ctx context.Context, key string) (interface{}, error)
	GetSet(ctx context.Context, key string, value interface{}) (interface{}, error)
	MGet(ctx context.Context, keys ...string) ([]interface{}, error)
	MSet(ctx context.Context, pairs ...interface{}) error
	Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error
	SetNX(ctx context.Context, key string, value interface{}, ttl time.Duration) (bool, error)

	BLPop(ctx context.Context, timeout time.Duration, keys ...string) ([]string, error)
	LPop(ctx context.Context, key string) (string, error)
	LLen(ctx context.Context, key string) (int64, error)
	LPush(ctx context.Context, key string, values ...interface{}) (int64, error)
	LRem(ctx context.Context, key string, count int64, value interface{}) (int64, error)
	RPush(ctx context.Context, key string, values ...interface{}) (int64, error)
	RPop(ctx context.Context, key string) (string, error)

	HDel(ctx context.Context, key string, fields ...string) (int64, error)
	HExists(ctx context.Context, key string, field string) (bool, error)
	HGet(ctx context.Context, key string, field string) (string, error)
	HGetAll(ctx context.Context, key string) (map[string]string, error)
	HKeys(ctx context.Context, key string) ([]string, error)
	HMGet(ctx context.Context, key string, fields ...string) ([]interface{}, error)
	HMSet(ctx context.Context, key string, pairs map[string]interface{}) error
	HSet(ctx context.Context, key string, field string, value interface{}) error
	HSetNX(ctx context.Context, key string, field string, value interface{}) (bool, error)

	SAdd(ctx context.Context, key string, values ...interface{}) (int64, error)
	SCard(ctx context.Context, key string) (int64, error)
	SDiff(ctx context.Context, keys ...string) ([]string, error)
	SDiffStore(ctx context.Context, destination string, keys ...string) (int64, error)
	SInter(ctx context.Context, keys ...string) ([]string, error)
	SInterStore(ctx context.Context, destination string, keys ...string) (int64, error)
	SMembers(ctx context.Context, key string) ([]string, error)
	SIsMember(ctx context.Context, key string, value interface{}) (bool, error)
	SMove(ctx context.Context, sourceKey string, destKey string, member interface{}) (bool, error)
	SPop(ctx context.Context, key string) (string, error)
	SRem(ctx context.Context, key string, values ...interface{}) (int64, error)
	SRandMember(ctx context.Context, key string) (string, error)
	SUnion(ctx context.Context, keys ...string) ([]string, error)
	SUnionStore(ctx context.Context, destination string, keys ...string) (int64, error)

	Decr(ctx context.Context, key string) (int64, error)
	DecrBy(ctx context.Context, key string, amount int64) (int64, error)
	Incr(ctx context.Context, key string) (int64, error)
	IncrBy(ctx context.Context, key string, amount int64) (int64, error)

	PFAdd(ctx context.Context, key string, els ...interface{}) (int64, error)
	PFCount(ctx context.Context, keys ...string) (int64, error)
	PFMerge(ctx context.Context, dest string, keys ...string) (string, error)

	ZAdd(ctx context.Context, key string, score float64, member string) (int64, error)
	ZAddArgs(ctx context.Context, args ZAddArgs) (int64, error)
	ZAddArgsIncr(ctx context.Context, args ZAddArgs) (float64, error)
	ZCard(ctx context.Context, key string) (int64, error)
	ZCount(ctx context.Context, key string, min string, max string) (int64, error)
	ZIncrBy(ctx context.Context, key string, increment float64, member string) (float64, error)
	ZScore(ctx context.Context, key string, member string) (float64, error)
	ZMScore(ctx context.Context, key string, members ...string) ([]float64, error)
	ZRange(ctx context.Context, key string, start int64, stop int64) ([]string, error)
	ZRangeArgs(ctx context.Context, args ZRangeArgs) ([]string, error)
	ZRangeArgsWithScore(ctx context.Context, args ZRangeArgs) ([]Z, error)
	ZRandMember(ctx context.Context, key string, count int) ([]string, error)
	ZRank(ctx context.Context, key string, member string) (int64, error)
	ZRem(ctx context.Context, key string, members ...string) (int64, error)
	ZRevRank(ctx context.Context, key string, member string) (int64, error)

	IsAlive(ctx context.Context) bool

	Pipeline() Pipeliner
}

func NewClient

func NewClient(config cfg.Config, logger log.Logger, name string) (Client, error)

func NewClientWithInterfaces

func NewClientWithInterfaces(logger log.Logger, baseRedis baseRedis.Cmdable, executor exec.Executor, settings *Settings) Client

func ProvideClient

func ProvideClient(ctx context.Context, config cfg.Config, logger log.Logger, name string) (Client, error)

type Dialer

type Dialer func(logger log.Logger, settings *Settings) func(context.Context, string, string) (net.Conn, error)

type ErrCmder

type ErrCmder interface {
	Err() error
}

type Naming

type Naming struct {
	Pattern string `cfg:"pattern,nodecode" default:"{name}.{group}.redis.{env}.{family}"`
}

type Pipeliner

type Pipeliner interface {
	baseRedis.Pipeliner
}

type Settings

type Settings struct {
	cfg.AppId
	Name            string `cfg:"name"`
	Dialer          string `cfg:"dialer" default:"tcp"`
	Address         string `cfg:"address" default:"127.0.0.1:6379"`
	Naming          Naming `cfg:"naming"`
	BackoffSettings exec.BackoffSettings
}

func ReadSettings

func ReadSettings(config cfg.Config, name string) *Settings

type SrvNamingFactory

type SrvNamingFactory func(appId cfg.AppId, name string) string

type Z

type Z struct {
	Score  float64
	Member interface{}
}

type ZAddArgs

type ZAddArgs struct {
	Key     string
	NX      bool
	XX      bool
	LT      bool
	GT      bool
	Ch      bool
	Incr    bool
	Members []Z
}

type ZRangeArgs

type ZRangeArgs struct {
	Key     string
	Start   interface{}
	Stop    interface{}
	ByScore bool
	ByLex   bool
	Rev     bool
	Offset  int64
	Count   int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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