xredis

package
v1.19.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

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

Types

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"`
}

type RedisCounter

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

RedisCounter Redis 计数器

func NewRedisCounter

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

func (*RedisCounter) Expire

func (c *RedisCounter) Expire(duration time.Duration) error

func (*RedisCounter) Incr

func (c *RedisCounter) Incr() int64

type RedisLocker

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

RedisLocker Redis 锁

func NewRedisLocker

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

func (*RedisLocker) Key

func (l *RedisLocker) Key() string

func (*RedisLocker) Lock

func (l *RedisLocker) Lock(values ...interface{}) bool

func (*RedisLocker) Unlock

func (l *RedisLocker) Unlock(values ...interface{}) bool

func (*RedisLocker) WithConfig

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

Jump to

Keyboard shortcuts

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