eredis

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MAX_IDLE        = 50
	MAX_ACTIVE      = 100
	IDLE_TIMEOUT    = 300
	READ_TIMEOUT    = 500
	WRITE_TIMEOUT   = 500
	CONNECT_TIMEOUT = 1000
)
View Source
const (
	UnlockLua = `` /* 169-byte string literal not displayed */

)

Variables

View Source
var (
	ErrRespNil                = errors.New("nil returned")
	ErrRedisNotInit           = errors.New("Redis Not Init")
	ErrRedisLogNotInit        = errors.New("Redis Logger Not Init")
	ErrRedisNotConfigured     = errors.New("RedisName Is Not Configured")
	ErrRedisAddrNotConfigured = errors.New("Redis Addr Is Not Configured")
)

Functions

func Close

func Close()

func InitRedis

func InitRedis(ctx context.Context, redisInfos []RedisInfo, rdc RedisDynamicConfiguration, logger RedisLog) error

Types

type Redis

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

func GetClient

func GetClient(redisName string) (*Redis, error)

func NewRedis

func NewRedis(ctx context.Context, i RedisInfo) (*Redis, error)

func (*Redis) Close

func (r *Redis) Close() error

关闭一个链接池

func (*Redis) Del

func (r *Redis) Del(args ...interface{}) (count int64, err error)

func (*Redis) Exec

func (r *Redis) Exec(cmd string, key interface{}, args ...interface{}) (interface{}, error)

func (*Redis) GetInt64

func (r *Redis) GetInt64(key string) (int64, error)

func (*Redis) GetString

func (r *Redis) GetString(key string) (string, error)

func (*Redis) GetStringMap

func (r *Redis) GetStringMap(key string) (map[string]string, error)

func (*Redis) Lock

func (r *Redis) Lock(key string, expired int64) (version int64, ok bool, err error)

func (*Redis) Script

func (r *Redis) Script(keyCount int, data string, args []string) (interface{}, error)

func (*Redis) Set

func (r *Redis) Set(key string, value interface{}) error

func (*Redis) Unlock

func (r *Redis) Unlock(key string, version int64) (ok bool, err error)

type RedisClients

type RedisClients struct {
	Rs map[string]*Redis
	// contains filtered or unexported fields
}

type RedisDynamicConfiguration

type RedisDynamicConfiguration interface {
	GetRedisConfig() ([]RedisInfo, error)
	GetRedisConfigTime() time.Duration
}

type RedisInfo

type RedisInfo struct {
	RedisName      string
	Addr           string
	MaxIdle        int
	MaxActive      int
	IdleTimeout    int64
	ReadTimeout    int64
	WriteTimeout   int64
	ConnectTimeout int64
	Password       string
	Wait           bool
	Database       int
}

type RedisLog

type RedisLog interface {
	Debugf(f string, args ...interface{})
	Infof(f string, args ...interface{})
	Warnf(f string, args ...interface{})
	Errorf(f string, args ...interface{})
}

Jump to

Keyboard shortcuts

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