redis

package
v0.0.0-...-08c5772 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decr

func Decr(client *redis.Client, ctx context.Context, key string) int64

Decr 自减 1

func DecrBy

func DecrBy(client *redis.Client, ctx context.Context, key string, val int64) int64

DecrBy 自减指定的值

func Del

func Del(client *redis.Client, ctx context.Context, keys ...string) (bool, int64)

Del 批量删除字符串

func Expire

func Expire(client *redis.Client, ctx context.Context, key string, exp time.Duration) bool

Expire 设置 key 的过期时间

func Get

func Get(client *redis.Client, ctx context.Context, key string) string

Get 获取字符串

func GetExpire

func GetExpire(client *redis.Client, ctx context.Context, key string) time.Duration

GetExpire 获取 key 的过期时间

func HasKey

func HasKey(client *redis.Client, ctx context.Context, key string) bool

HasKey 判断 key 是否存在

func HmDel

func HmDel(client *redis.Client, ctx context.Context, key string, fields ...string) (bool, int64)

HmDel 删除哈希表 key 中的一个或多个指定域,不存在的域将被忽略

func HmGet

func HmGet(client *redis.Client, ctx context.Context, key string, field string) []any

HmGet 获取哈希表 key 中给定域 field 的值

func HmGetAll

func HmGetAll(client *redis.Client, ctx context.Context, key string) map[string]string

HmGetAll 获取哈希表 key 中的所有域和值

func HmHasKey

func HmHasKey(client *redis.Client, ctx context.Context, key string, field string) bool

HmHasKey 判断哈希表 key 中,给定域 field 是否存在

func HmIncr

func HmIncr(client *redis.Client, ctx context.Context, key string, field string, val int64) int64

HmIncr 哈希表 key 中给定域 field 的值加上增量 increment

func HmIncrFloat

func HmIncrFloat(client *redis.Client, ctx context.Context, key string, field string, val float64) float64

HmIncrFloat 哈希表 key 中给定域 field 的值加上浮点数增量 increment

func HmKeys

func HmKeys(client *redis.Client, ctx context.Context, key string) []string

HmKeys 获取哈希表 key 中的所有域 (field)

func HmLen

func HmLen(client *redis.Client, ctx context.Context, key string) int64

HmLen 获取哈希表 key 中域的数量

func HmSet

func HmSet(client *redis.Client, ctx context.Context, key string, field string, val any)

HmSet 设置哈希表 key 中的域 field 的值为 val

func HmSetAll

func HmSetAll(client *redis.Client, ctx context.Context, key string, val map[string]any)

HmSetAll 同时将多个 field-value (域-值)对设置到哈希表 key 中 (批量设置) 例如: {"name": "zhangsan", "age": 18}

func HmVals

func HmVals(client *redis.Client, ctx context.Context, key string) []string

HmVals 获取哈希表 key 中所有值 (value)

func Incr

func Incr(client *redis.Client, ctx context.Context, key string) int64

Incr 自增 1

func IncrBy

func IncrBy(client *redis.Client, ctx context.Context, key string, val int64) int64

IncrBy 自增指定的值

func LIndex

func LIndex(client *redis.Client, ctx context.Context, key string, index int64) string

LIndex 根据索引获取列表中的元素

func LLen

func LLen(client *redis.Client, ctx context.Context, key string) int64

LLen 获取列表长度

func LPush

func LPush(client *redis.Client, ctx context.Context, key string, values ...any)

LPush 将一个或多个值插入到列表头部

func LPushX

func LPushX(client *redis.Client, ctx context.Context, key string, value any)

LPushX 将一个值插入到已存在的列表头部

func LRPush

func LRPush(client *redis.Client, ctx context.Context, key string, values ...any)

LRPush 将一个或多个值插入到列表尾部

func LRange

func LRange(client *redis.Client, ctx context.Context, key string, start int64, stop int64) []string

LRange 获取列表指定范围内的元素

func LRem

func LRem(client *redis.Client, ctx context.Context, key string, count int64, value any)

LRem 根据参数 count 的值,移除列表中与参数 value 相等的元素

func LSet

func LSet(client *redis.Client, ctx context.Context, key string, index int64, value any)

LSet 通过索引设置列表元素的值

func SAdd

func SAdd(client *redis.Client, ctx context.Context, key string, members ...any) int64

SAdd 向集合添加一个或多个成员

func SCard

func SCard(client *redis.Client, ctx context.Context, key string) int64

SCard 获取集合的成员数

func SIsMember

func SIsMember(client *redis.Client, ctx context.Context, key string, member string) bool

SIsMember 判断 member 元素是否是集合 key 的成员

func SMembers

func SMembers(client *redis.Client, ctx context.Context, key string) []string

SMembers 获取集合中的所有成员

func SMembersMap

func SMembersMap(client *redis.Client, ctx context.Context, key string) map[string]struct{}

SMembersMap 获取集合中的所有成员

func SRem

func SRem(client *redis.Client, ctx context.Context, key string, members ...any) int64

SRem 移除集合中一个或多个成员

func Set

func Set(client *redis.Client, ctx context.Context, key string, val any)

Set 保存字符串但不设置过期时间

func SetExpiration

func SetExpiration(client *redis.Client, ctx context.Context, key string, val any, exp time.Duration)

SetExpiration 保存字符串并设置过期时间

Types

This section is empty.

Jump to

Keyboard shortcuts

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