redispool

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: GPL-3.0 Imports: 7 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 added in v0.2.2

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

GetLock 获取锁

func GetRedis added in v0.2.3

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 added in v0.2.3

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

InitRedisWithConfig 初始化redis连接

func IsExistKey

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

func LPush added in v0.2.8

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

func LRem added in v0.2.8

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

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

func Lock added in v0.2.7

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

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

func LockWithTimeout added in v0.2.7

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

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

func RPop added in v0.2.8

func RPop(key string) (string, error)

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

func RPopLPush added in v0.2.8

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 added in v0.2.8

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 added in v0.2.7

func UnLock(key string) error

UnLock 释放锁

func ZAdd added in v0.2.8

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

func ZCount added in v0.2.8

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

func ZIncrBy added in v0.2.8

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

func ZRange added in v0.2.8

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

func ZRangeByScore added in v0.2.8

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

func ZRangeByScoreWithScores added in v0.2.8

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

func ZRangeWithScores added in v0.2.8

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

func ZRem added in v0.2.8

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) IsExist

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

func (*Cache) LPush added in v0.2.8

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

func (*Cache) LRem added in v0.2.8

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

func (*Cache) RPop added in v0.2.8

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

func (*Cache) RPopLPush added in v0.2.8

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 added in v0.2.8

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 added in v0.2.8

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

func (*Cache) ZCount added in v0.2.8

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

func (*Cache) ZIncrBy added in v0.2.8

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

func (*Cache) ZRange added in v0.2.8

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

func (*Cache) ZRangeByScore added in v0.2.8

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

func (*Cache) ZRangeByScoreWithScores added in v0.2.8

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

func (*Cache) ZRangeWithScores added in v0.2.8

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

func (*Cache) ZRem added in v0.2.8

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