redispool

package
v0.4.12 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Del

func Del(key string) error

func GetJSON

func GetJSON(key string, v interface{}) error

func GetLock

func GetLock(key string, expired time.Duration) bool

GetLock 获取锁

func GetRedis

func GetRedis() (*redis.Client, error)

GetRedis 获取redis连接, 可能为nil

func GetString

func GetString(key string) (string, error)

func InitCache

func InitCache(cli *redis.Client)

func InitRedis

func InitRedis(group, key string) error

InitRedis 初始化redis连接

func InitRedisWithConfig

func InitRedisWithConfig(cfg *redis.Options) (*redis.Client, error)

InitRedisWithConfig 初始化redis连接

func IsExistKey

func IsExistKey(key string) (bool, time.Duration)

func LPush

func LPush(key string, values ...string) error

func LRem

func LRem(key string, count int64, value string) (int64, error)

LRem ... 删除列表指定数量的value,返回删除的数量,为0则该值不存在

func Lock

func Lock(key string, expired time.Duration) error

Lock 释放锁 key: 锁的key expired: 锁的超时时间

func LockWithTimeout

func LockWithTimeout(key string, expired, interval, timeout time.Duration) bool

LockWithTimeout 获取锁 key: 锁的key expired: 锁的超时时间 interval: 获取锁的间隔时间 timeout: 获取锁的超时时间

func RPop

func RPop(key string) (string, error)

RPop if key not exist in redis,return redis.Nil error

func RPopLPush

func RPopLPush(src, dst string) (string, error)

RPopLPush if key not exist in redis,return redis.Nil error

func Redis

func Redis() *redis.Client

Redis 获取redis连接

func SetJSON

func SetJSON(key string, v interface{}, expired time.Duration) error

func SetNX

func SetNX(key, data string, expired time.Duration) (bool, error)

func SetString

func SetString(key, value string, timeout time.Duration) error

func Std

func Std() *redis.Client

func UnLock

func UnLock(key string) error

UnLock 释放锁

func ZAdd

func ZAdd(key string, members ...redis.Z) (int64, error)

func ZCount

func ZCount(key string, min, max string) (int64, error)

func ZIncrBy

func ZIncrBy(key string, increment float64, member string) (float64, error)

func ZRange

func ZRange(key string, start, stop int64) ([]string, error)

func ZRangeByScore

func ZRangeByScore(key string, by *redis.ZRangeBy) ([]string, error)

func ZRangeByScoreWithScores

func ZRangeByScoreWithScores(key string, by *redis.ZRangeBy) ([]redis.Z, error)

func ZRangeWithScores

func ZRangeWithScores(key string, start, stop int64) ([]redis.Z, error)

func ZRem

func ZRem(key string, member ...interface{}) (int64, error)

Types

type Cache

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

func CacheInstance

func CacheInstance() *Cache

func (*Cache) Del

func (c *Cache) Del(key string) error

func (*Cache) Get

func (c *Cache) Get(key string) (string, error)

func (*Cache) HDel

func (c *Cache) HDel(key string, fields ...string) (int64, error)

func (*Cache) HExists

func (c *Cache) HExists(key string, field string) (bool, error)

func (*Cache) HGet

func (c *Cache) HGet(key string, field string) (string, error)

HGet 返回给定字段的值。如果给定的字段或 key 不存在时,返回 nil

func (*Cache) HMSet

func (c *Cache) HMSet(key string, values ...string) (int64, error)

HMSet 设置多个值,values 按照field1,value1,field2,value2 ...的顺序进行赋值

func (*Cache) HSet

func (c *Cache) HSet(key string, field, value string) (int64, error)

func (*Cache) HSetNX

func (c *Cache) HSetNX(key string, field, value string) (bool, error)

HSetNX Redis HSETNX 命令用于为哈希表中不存在的字段赋值 。如果字段已经存在于哈希表中,操作无效。

func (*Cache) IsExist

func (c *Cache) IsExist(key string) bool

func (*Cache) LPush

func (c *Cache) LPush(key string, values ...string) error

func (*Cache) LRem

func (c *Cache) LRem(key string, count int64, value string) (int64, error)

func (*Cache) RPop

func (c *Cache) RPop(key string) (string, error)

func (*Cache) RPopLPush

func (c *Cache) RPopLPush(src, dst string) (string, error)

func (*Cache) SetEx

func (c *Cache) SetEx(key, data string, expired time.Duration) error

func (*Cache) SetNX

func (c *Cache) SetNX(key, data string, expired time.Duration) (bool, error)

func (*Cache) TTL

func (c *Cache) TTL(key string) time.Duration

func (*Cache) ZAdd

func (c *Cache) ZAdd(key string, members ...redis.Z) (int64, error)

func (*Cache) ZCount

func (c *Cache) ZCount(key string, min, max string) (int64, error)

func (*Cache) ZIncrBy

func (c *Cache) ZIncrBy(key string, increment float64, member string) (float64, error)

func (*Cache) ZRange

func (c *Cache) ZRange(key string, start, stop int64) ([]string, error)

func (*Cache) ZRangeByScore

func (c *Cache) ZRangeByScore(key string, by *redis.ZRangeBy) ([]string, error)

func (*Cache) ZRangeByScoreWithScores

func (c *Cache) ZRangeByScoreWithScores(key string, by *redis.ZRangeBy) ([]redis.Z, error)

func (*Cache) ZRangeWithScores

func (c *Cache) ZRangeWithScores(key string, start, stop int64) ([]redis.Z, error)

func (*Cache) ZRem

func (c *Cache) ZRem(key string, member ...interface{}) (int64, error)

Jump to

Keyboard shortcuts

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