xredis

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogger added in v1.20.6

func SetLogger(logger Logging)

Types

type Client added in v1.20.6

type Client struct {
	*redis.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *RedisConfig) (client *Client, err error)

func (*Client) DisableKeyPrefix added in v1.20.8

func (c *Client) DisableKeyPrefix()

func (*Client) EnableKeyPrefix added in v1.20.8

func (c *Client) EnableKeyPrefix()

func (*Client) KeyPrefix added in v1.20.6

func (c *Client) KeyPrefix() string

type Logging added in v1.20.6

type Logging interface {
	Printf(ctx context.Context, format string, v ...interface{})
}

type RedisConfig

type RedisConfig struct {
	Addr         string `json:"addr"`
	Password     string `json:"password"`
	DB           int    `json:"DB"`
	DialTimeout  int64  `json:"dialTimeout"`
	ReadTimeout  int64  `json:"readTimeout"`
	WriteTimeout int64  `json:"writeTimeout"`
	IdleTimeout  int64  `json:"idleTimeout"` // 连接生效时间,默认5分钟
	MaxRetries   int    `json:"maxRetries"`
	PoolSize     int    `json:"poolSize"`
	MinIdleConn  int    `json:"minIdleConn"`
	KeyPrefix    string `json:"keyPrefix"`
}

type RedisCounter

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

RedisCounter Redis 计数器

func NewRedisCounter

func NewRedisCounter(client *Client, key string, keyFmtArgs ...interface{}) *RedisCounter

func (*RedisCounter) Expire

func (c *RedisCounter) Expire(ctx context.Context, duration time.Duration) error

func (*RedisCounter) Incr

func (c *RedisCounter) Incr(ctx context.Context) int64

type RedisLocker

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

RedisLocker Redis 锁

func NewRedisLocker

func NewRedisLocker(client *Client, key string, keyFmtArgs ...interface{}) *RedisLocker

func (*RedisLocker) Key

func (l *RedisLocker) Key() string

func (*RedisLocker) Lock

func (l *RedisLocker) Lock(ctx context.Context, values ...interface{}) bool

func (*RedisLocker) Unlock

func (l *RedisLocker) Unlock(ctx context.Context, values ...interface{}) bool

func (*RedisLocker) WithConfig

func (l *RedisLocker) WithConfig(retries int, interval, expiration time.Duration) *RedisLocker

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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