xredis

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAndJsonUnmarshal

func GetAndJsonUnmarshal(r *Redis, key string, obj interface{}) error

反序列化

func SetExAndJsonMarshalHelper

func SetExAndJsonMarshalHelper(r *Redis, key string, expire int32, obj interface{}) error

序列化

Types

type Option

type Option func(*options)

func WithIdleTimeout

func WithIdleTimeout(idleTimeout time.Duration) Option

func WithMaxActive

func WithMaxActive(maxActive int) Option

func WithMaxIdle

func WithMaxIdle(maxIdle int) Option

func WithWait

func WithWait(wait bool) Option

type Redis

type Redis struct {
	*redis.Pool
}

func NewRedis

func NewRedis(conf RedisConfig, options ...Option) *Redis

func NewRedisByPool

func NewRedisByPool(pool *redis.Pool) *Redis

func (*Redis) Del

func (r *Redis) Del(key string) error

func (*Redis) Do

func (r *Redis) Do(commandName string, args ...interface{}) (reply interface{}, err error)

func (*Redis) DoInExpiredAt

func (r *Redis) DoInExpiredAt(f func() error, key string, expiredAt int) error

f()函数操作 防止并发上锁和限制频率,expiredAt秒内操作一次

func (*Redis) DoWithLock

func (r *Redis) DoWithLock(f func() error, key string) error

f()函数操作 防止并发上锁,默认30秒

func (*Redis) IncUtilToNight

func (r *Redis) IncUtilToNight(key string, v int) (int, error)

func (*Redis) IncWithInitialTime

func (r *Redis) IncWithInitialTime(key string, expired int, v int) (int, error)

设置目标key增加v,并且当key不存在的时候生存时间为t秒,返回增加后的值

func (*Redis) TryLock

func (r *Redis) TryLock(key string, expired int) bool

type RedisConfig

type RedisConfig struct {
	Address  string `json:"addr"`
	Password string `json:"password"`
	DBNum    int    `json:"db"`
}

RedisConfig RedisConfig

Jump to

Keyboard shortcuts

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