redis

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RDB *redis.Client
)

Functions

func Delete

func Delete(keys ...string) error

Delete 删除key

func Eval

func Eval(script string, keys []string, args ...interface{}) error

func ExistKey

func ExistKey(key string) bool

ExistKey key是否存在

func ExpireTime

func ExpireTime(key string, t time.Duration) error

ExpireTime 设置key过期时间

func Get

func Get(key string) (string, error)

Get 获取string

func GetExpire

func GetExpire(key string) (time.Duration, error)

GetExpire 获得 key 的过期时间

func HDel

func HDel(key string, fields ...string) (int64, error)

HDel 删除哈希表中的一个或多个字段

func HExists

func HExists(key, field string) (bool, error)

HExists 检查哈希表中给定字段是否存在

func HGet

func HGet(key, field string) (string, error)

HGet 获取hash字段值

func HGetAll

func HGetAll(key string) (map[string]string, error)

HGetAll 获取所有key 转成map

func HKeys

func HKeys(key string) ([]string, error)

HKeys 获取哈希表中所有的字段

func HLen

func HLen(key string) (int64, error)

HLen 获取哈希表中字段的数量

func HSet

func HSet(key, field string, value any) error

HSet 设置单个哈希表字段

func HSetMap

func HSetMap(key string, fields map[string]any) error

HSetMap 设置map对象位hash表

func HSetMapExpire

func HSetMapExpire(key string, fields map[string]any, expireTime time.Duration) error

HSetMapExpire 设置map对象位hash表

func HVals

func HVals(key string) ([]string, error)

HVals 获取哈希表中所有字段的值

func Init

func Init(cfg *config.Redis)

func LIndex

func LIndex(key string, index int64) (string, error)

LIndex 获取 Redis 的 list 中指定值的元素

func LPop

func LPop(key string) (string, error)

LPop 获取 Redis 的 list 删除左边的元素

func LPush

func LPush(key string, values ...interface{}) error

LPush 将元素插入 Redis 的 list 头部

func LRange

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

LRange 获取 Redis 的 list 中指定范围的元素

func Publish

func Publish(channel, message string)

Publish 发布消息

func RPop

func RPop(key string) (string, error)

RPop 获取 Redis 的 list 删除右边的元素

func RPush

func RPush(key string, values ...interface{}) error

RPush 将元素插入 Redis 的 list 尾部

func RemoveExpire

func RemoveExpire(key string) error

RemoveExpire 删除key过期时间

func Rename

func Rename(oldKey, newKey string) (bool, error)

Rename 更改key的名字

func SAdd

func SAdd(key string, members ...interface{}) error

SAdd 无序集合添加元素

func SIsMember

func SIsMember(key string, member interface{}) (bool, error)

SIsMember 无序集合判断是否属于该集合

func SMembers

func SMembers(key string) ([]string, error)

SMembers 无序集合获取所有成员

func SRem

func SRem(key string, members ...interface{}) error

SRem 无序集合删除成员

func Set

func Set(key string, value interface{}) error

Set 设置string

func SetExpire

func SetExpire(key string, value interface{}, expireTime time.Duration) error

SetExpire 设置string

func Subscribe

func Subscribe(channel string, cb func(string)) *redis.PubSub

Subscribe 订阅消息

func ZAdd

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

ZAdd 添加元素

func ZRange

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

ZRange 获取范围内元素

func ZRank

func ZRank(key string, member string) (int64, error)

ZRank 有序集合中指定成员的序号

func ZRem

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

ZRem 删除

Types

This section is empty.

Jump to

Keyboard shortcuts

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