redis

package
v0.3.34 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(key, value string) (int64, error)

追加到值的末尾

func Dec

func Dec(key string, v ...int64) (result int64, err error)

自减

func Del

func Del(keys ...string) (int64, error)

删除缓存项

func Exists

func Exists(keys ...string) (int64, error)

检测缓存项是否存在

func Expire

func Expire(key string, exp int64) (bool, error)

设置过期时间,以秒计

func ExpireAt

func ExpireAt(key string, tm time.Time) (bool, error)

设置过期时间,指定时间点

func Get

func Get[t any](key string) (*t, error)

获取指定 key 的指定类型值

func GetRange

func GetRange(key string, start, end int64) (string, error)

字符串截取

func GetString

func GetString(key string) (string, error)

获取指定 key 的字符串值

func HDel

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

删除某个元素

func HExists

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

判断元素是否存在

func HGet

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

获取某个元素

func HGetAll

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

获取某个元素

func HLen

func HLen(key string) (int64, error)

获取长度

func HMSet

func HMSet(key string, values ...any) (bool, error)

批量设置

func HSet

func HSet(key string, values ...any) (int64, error)

设置

func Inc

func Inc(key string, v ...int64) (result int64, err error)

自增

func Keys

func Keys(pattern string) ([]string, error)

根据正则获取keys

func LIndex

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

获取链表下标对应的元素

func LInsert

func LInsert(key, op string, pivot, value any) (int64, error)

在某个位置插入新元素

func LLen

func LLen(key string) (int64, error)

获取链表元素个数

func LPop

func LPop(key string) (string, error)

从链表左侧弹出数据

func LPush

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

将元素从左侧压入链表

func LRange

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

获取某个选定范围的元素集

func LRem

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

根据值移除元素

func LSet

func LSet(key string, index int64, value any) error

设置某个元素的值

func NewClient

func NewClient() *redis.Client

func PTTL

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

获取某个键的剩余有效期,以毫秒为单位

func RPop

func RPop(key string) (string, error)

从链表右侧弹出数据

func RPush

func RPush(key string, values ...any) (int64, error)

将元素从右侧压入链表

func SAdd

func SAdd(key string, members ...any) (int64, error)

添加元素

func SCard

func SCard(key string) (int64, error)

获取集合元素个数

func SDiff

func SDiff(keys ...string) ([]string, error)

差集

func SInter

func SInter(keys ...string) ([]string, error)

交集

func SIsMember

func SIsMember(key string, member any) (bool, error)

判断元素是否在集合中

func SMembers

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

获取所有成员

func SPop

func SPop(key string) (string, error)

随机移除一个元素,并返回

func SPopN

func SPopN(key string, count int64) ([]string, error)

随机移除多个元素,并返回

func SRandMember

func SRandMember(key string) (string, error)

随机获取一个元素

func SRandMemberN

func SRandMemberN(key string, count int64) ([]string, error)

随机获取多个元素

func SRem

func SRem(key string, members ...any) (int64, error)

删除集合里指定的值

func SUnion

func SUnion(keys ...string) ([]string, error)

并集

func Set

func Set(key string, val any, expiration ...int64) error

设置指定 key 的值

func StrLen

func StrLen(key string) (int64, error)

返回 key 所储存的字符串值的长度

func TTL

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

获取某个键的剩余有效期,以秒为单位

func Type

func Type(key string) (string, error)

获取key对应值得类型

func ZAdd

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

添加元素

func ZCard

func ZCard(key string) (int64, error)

获取元素个数

func ZCount

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

获取区间内元素个数

func ZIncrBy

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

增加元素分值

func ZRange

func ZRange(key string, startStop ...int64) ([]string, error)

获取根据score排序后的数据段,升序

func ZRangeByScore

func ZRangeByScore(key string, opt *ZRangeBy) ([]string, error)

获取score过滤后排序的数据段,升序

func ZRank

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

获取某个元素在集合中的排名,升序

func ZRem

func ZRem(key string, members ...any) (int64, error)

删除元素

func ZRemRangeByRank

func ZRemRangeByRank(key string, start, stop int64) (int64, error)

根据排名来删除

func ZRemRangeByScore

func ZRemRangeByScore(key, start, stop string) (int64, error)

根据分值区间来删除

func ZRevRange

func ZRevRange(key string, startStop ...int64) ([]string, error)

获取根据score排序后的数据段,降序

func ZRevRangeByScore

func ZRevRangeByScore(key string, opt *ZRangeBy) ([]string, error)

获取score过滤后排序的数据段,降序

func ZRevRank

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

获取某个元素在集合中的排名,降序

func ZScore

func ZScore(key, member string) (float64, error)

获取元素的score

Types

type Z

type Z = redis.Z

type ZRangeBy

type ZRangeBy = redis.ZRangeBy

Jump to

Keyboard shortcuts

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