Documentation
¶
Index ¶
- Variables
- func MatchFilter(patterns []string, key string) bool
- type Empty
- type KRedis
- func (mr *KRedis) Del(keys ...string) (int64, error)
- func (mr *KRedis) Do(args ...any) (any, error)
- func (mr *KRedis) Dump(key string) (string, error)
- func (mr *KRedis) Exist(key string) (bool, error)
- func (that *KRedis) Expire(key string, expiration time.Duration) bool
- func (that *KRedis) ExpireAt(key string, tm time.Time) bool
- func (mr *KRedis) Get(key string) (any, error)
- func (that *KRedis) HDel(key string, fields ...string) error
- func (that *KRedis) HExists(key string, field string) (bool, error)
- func (that *KRedis) HGet(key string, field string) (any, error)
- func (that *KRedis) HGetAll(key string) (map[string]string, error)
- func (that *KRedis) HKeys(ctx context.Context, key string) ([]string, error)
- func (that *KRedis) HLen(key string) (int64, error)
- func (that *KRedis) HMGet(key string, fields ...string) ([]any, error)
- func (that *KRedis) HMSet(key string, fields map[string]any) error
- func (that *KRedis) HSet(key string, field string, value any) error
- func (that *KRedis) HSetAll(key string, fields map[string]any) error
- func (that *KRedis) HSetNX(ctx context.Context, key, field string, value any) (bool, error)
- func (that *KRedis) HVals(ctx context.Context, key string) ([]string, error)
- func (that *KRedis) JsonDel(key string, path string) (int64, error)
- func (that *KRedis) JsonGet(key string, paths ...string) (string, error)
- func (that *KRedis) JsonMerge(key string, path string, value string) error
- func (that *KRedis) JsonObjKeys(key string, path string) ([]string, error)
- func (that *KRedis) JsonObjLen(key string, path string) ([]int64, error)
- func (that *KRedis) JsonSet(key string, path string, value string) error
- func (that *KRedis) JsonType(key string, path string) ([]string, error)
- func (that *KRedis) LIndex(key string, index int64) (string, error)
- func (that *KRedis) LInsert(key string, position string, pivot any, value any) (int64, error)
- func (that *KRedis) LLen(key string) (int64, error)
- func (that *KRedis) LPop(key string) (string, error)
- func (that *KRedis) LPush(key string, values ...any) (int64, error)
- func (that *KRedis) LPushX(key string, values ...any) (int64, error)
- func (that *KRedis) LRange(key string, start int64, stop int64) ([]string, error)
- func (that *KRedis) LRem(key string, count int64, value any) (int64, error)
- func (that *KRedis) LSet(key string, index int64, value any) error
- func (that *KRedis) LTrim(key string, start int64, stop int64) error
- func (mr *KRedis) PSubscribe(timeout int, callback func(err error, topic string, payload any), ...)
- func (mr *KRedis) PSubscribeLow(callback func(err error, topic string, payload any), topics ...string)
- func (mr *KRedis) PSubscribeWithChanSize(timeout int, chanSize int, callback func(err error, topic string, payload any), ...)
- func (mr *KRedis) PTTL(key string) (time.Duration, error)
- func (mr *KRedis) Ping() bool
- func (mr *KRedis) Pipeline() redisHd.Pipeliner
- func (mr *KRedis) Publish(topic string, payload any) error
- func (that *KRedis) PublishArray(messages []*RedisMessage) []error
- func (that *KRedis) PublishArrayWithCtx(ctx *kcontext.ContextNode, messages []*RedisMessage) []error
- func (that *KRedis) RPop(key string) (string, error)
- func (that *KRedis) RPush(key string, values ...any) (int64, error)
- func (that *KRedis) RPushX(key string, values ...any) (int64, error)
- func (mr *KRedis) Restore(key string, ttl time.Duration, value string) (string, error)
- func (mr *KRedis) RestoreReplace(key string, ttl time.Duration, value string) (string, error)
- func (that *KRedis) SAdd(key string, members ...any) (int64, error)
- func (that *KRedis) SCard(key string) (int64, error)
- func (that *KRedis) SDiff(keys ...string) ([]string, error)
- func (that *KRedis) SDiffStore(destKey string, keys ...string) (int64, error)
- func (that *KRedis) SInter(keys ...string) ([]string, error)
- func (that *KRedis) SInterStore(destKey string, keys ...string) (int64, error)
- func (that *KRedis) SIsMember(key string, member any) (bool, error)
- func (that *KRedis) SMembers(key string) ([]string, error)
- func (that *KRedis) SMove(source, destination string, member any) (bool, error)
- func (that *KRedis) SPop(key string) (string, error)
- func (that *KRedis) SPopN(key string, count int64) ([]string, error)
- func (that *KRedis) SRandMember(key string) (string, error)
- func (that *KRedis) SRem(key string, members ...any) (int64, error)
- func (that *KRedis) SUnion(keys ...string) ([]string, error)
- func (that *KRedis) SUnionStore(destKey string, keys ...string) (int64, error)
- func (mr *KRedis) Scan(limit int, aboutTypes []string, ignoreKeys []string, includeKeys []string, ...) ([]*RedisRecord, error)
- func (mr *KRedis) ScanMatch(limit int, aboutTypes []string, ignoreKeys []string, includeKeys []string, ...) ([]*RedisRecord, error)
- func (mr *KRedis) Set(key string, value any, duration time.Duration) (bool, error)
- func (mr *KRedis) Stop()
- func (mr *KRedis) Subscribe(timeout int, callback func(err error, topic string, payload any), ...)
- func (mr *KRedis) SubscribeLow(callback func(err error, topic string, payload any), topics ...string)
- func (mr *KRedis) SubscribeWithoutTimeout(callback func(err error, topic string, payload any), topics ...string)
- func (mr *KRedis) SyncPSubscribe(timeout int, callback func(err error, topic string, payload any), ...)
- func (mr *KRedis) SyncPSubscribeLow(callback func(err error, topic string, payload any), topics ...string)
- func (mr *KRedis) SyncPSubscribeWithChanSize(timeout int, chanSize int, callback func(err error, topic string, payload any), ...)
- func (mr *KRedis) SyncSubscribe(timeout int, callback func(err error, topic string, payload any), ...)
- func (mr *KRedis) SyncSubscribeLow(callback func(err error, topic string, payload any), topics ...string)
- func (mr *KRedis) SyncSubscribeWithoutTimeout(callback func(err error, topic string, payload any), topics ...string)
- func (mr *KRedis) TTL(key string) (time.Duration, error)
- func (mr *KRedis) Type(key string) (string, error)
- type KRedisClient
- type KRedisCluster
- func (that *KRedisCluster) Del(keys ...string) (int64, error)
- func (that *KRedisCluster) Do(args ...any) (any, error)
- func (that *KRedisCluster) Dump(key string) (string, error)
- func (that *KRedisCluster) Exist(key string) (bool, error)
- func (that *KRedisCluster) Expire(key string, expiration time.Duration) bool
- func (that *KRedisCluster) ExpireAt(key string, tm time.Time) bool
- func (that *KRedisCluster) Get(key string) (any, error)
- func (that *KRedisCluster) HDel(key string, fields ...string) error
- func (that *KRedisCluster) HExists(key string, field string) (bool, error)
- func (that *KRedisCluster) HGet(key string, field string) (any, error)
- func (that *KRedisCluster) HGetAll(key string) (map[string]string, error)
- func (that *KRedisCluster) HKeys(ctx context.Context, key string) ([]string, error)
- func (that *KRedisCluster) HLen(key string) (int64, error)
- func (that *KRedisCluster) HMGet(key string, fields ...string) ([]any, error)
- func (that *KRedisCluster) HMSet(key string, fields map[string]any) error
- func (that *KRedisCluster) HSet(key string, field string, value any) error
- func (that *KRedisCluster) HSetAll(key string, fields map[string]any) error
- func (that *KRedisCluster) HSetNX(ctx context.Context, key, field string, value any) (bool, error)
- func (that *KRedisCluster) HVals(ctx context.Context, key string) ([]string, error)
- func (that *KRedisCluster) JsonDel(key string, path string) (int64, error)
- func (that *KRedisCluster) JsonGet(key string, paths ...string) (string, error)
- func (that *KRedisCluster) JsonMerge(key string, path string, value string) error
- func (that *KRedisCluster) JsonObjKeys(key string, path string) ([]string, error)
- func (that *KRedisCluster) JsonObjLen(key string, path string) ([]int64, error)
- func (that *KRedisCluster) JsonSet(key string, path string, value string) error
- func (that *KRedisCluster) JsonType(key string, path string) ([]string, error)
- func (that *KRedisCluster) LIndex(key string, index int64) (string, error)
- func (that *KRedisCluster) LInsert(key string, position string, pivot any, value any) (int64, error)
- func (that *KRedisCluster) LLen(key string) (int64, error)
- func (that *KRedisCluster) LPop(key string) (string, error)
- func (that *KRedisCluster) LPush(key string, values ...any) (int64, error)
- func (that *KRedisCluster) LPushX(key string, values ...any) (int64, error)
- func (that *KRedisCluster) LRange(key string, start int64, stop int64) ([]string, error)
- func (that *KRedisCluster) LRem(key string, count int64, value any) (int64, error)
- func (that *KRedisCluster) LSet(key string, index int64, value any) error
- func (that *KRedisCluster) LTrim(key string, start int64, stop int64) error
- func (that *KRedisCluster) PSubscribe(timeout int, callback func(err error, topic string, payload any), ...)
- func (that *KRedisCluster) PSubscribeLow(callback func(err error, topic string, payload any), topics ...string)
- func (that *KRedisCluster) PSubscribeWithChanSize(timeout int, chanSize int, callback func(err error, topic string, payload any), ...)
- func (that *KRedisCluster) PTTL(key string) (time.Duration, error)
- func (that *KRedisCluster) Ping() bool
- func (that *KRedisCluster) Pipeline() redisHd.Pipeliner
- func (that *KRedisCluster) Publish(topic string, payload any) error
- func (that *KRedisCluster) PublishArray(messages []*RedisMessage) []error
- func (that *KRedisCluster) PublishArrayWithCtx(ctx *kcontext.ContextNode, messages []*RedisMessage) []error
- func (that *KRedisCluster) RPop(key string) (string, error)
- func (that *KRedisCluster) RPush(key string, values ...any) (int64, error)
- func (that *KRedisCluster) RPushX(key string, values ...any) (int64, error)
- func (that *KRedisCluster) Restore(key string, ttl time.Duration, value string) (string, error)
- func (that *KRedisCluster) RestoreReplace(key string, ttl time.Duration, value string) (string, error)
- func (that *KRedisCluster) SAdd(key string, members ...any) (int64, error)
- func (that *KRedisCluster) SCard(key string) (int64, error)
- func (that *KRedisCluster) SDiff(keys ...string) ([]string, error)
- func (that *KRedisCluster) SDiffStore(destKey string, keys ...string) (int64, error)
- func (that *KRedisCluster) SInter(keys ...string) ([]string, error)
- func (that *KRedisCluster) SInterStore(destKey string, keys ...string) (int64, error)
- func (that *KRedisCluster) SIsMember(key string, member any) (bool, error)
- func (that *KRedisCluster) SMembers(key string) ([]string, error)
- func (that *KRedisCluster) SMove(source, destination string, member any) (bool, error)
- func (that *KRedisCluster) SPop(key string) (string, error)
- func (that *KRedisCluster) SPopN(key string, count int64) ([]string, error)
- func (that *KRedisCluster) SRandMember(key string) (string, error)
- func (that *KRedisCluster) SRem(key string, members ...any) (int64, error)
- func (that *KRedisCluster) SUnion(keys ...string) ([]string, error)
- func (that *KRedisCluster) SUnionStore(destKey string, keys ...string) (int64, error)
- func (that *KRedisCluster) Scan(limit int, aboutTypes []string, ignoreKeys []string, includeKeys []string, ...) ([]*RedisRecord, error)
- func (that *KRedisCluster) ScanMatch(limit int, aboutTypes []string, ignoreKeys []string, includeKeys []string, ...) ([]*RedisRecord, error)
- func (that *KRedisCluster) Set(key string, value any, duration time.Duration) (bool, error)
- func (that *KRedisCluster) Stop()
- func (that *KRedisCluster) Subscribe(timeout int, callback func(err error, topic string, payload any), ...)
- func (that *KRedisCluster) SubscribeLow(callback func(err error, topic string, payload any), topics ...string)
- func (that *KRedisCluster) SubscribeWithoutTimeout(callback func(err error, topic string, payload any), topics ...string)
- func (that *KRedisCluster) SyncPSubscribe(timeout int, callback func(err error, topic string, payload any), ...)
- func (that *KRedisCluster) SyncPSubscribeLow(callback func(err error, topic string, payload any), topics ...string)
- func (that *KRedisCluster) SyncPSubscribeWithChanSize(timeout int, chanSize int, callback func(err error, topic string, payload any), ...)
- func (that *KRedisCluster) SyncSubscribe(timeout int, callback func(err error, topic string, payload any), ...)
- func (that *KRedisCluster) SyncSubscribeLow(callback func(err error, topic string, payload any), topics ...string)
- func (that *KRedisCluster) SyncSubscribeWithoutTimeout(callback func(err error, topic string, payload any), topics ...string)
- func (that *KRedisCluster) TTL(key string) (time.Duration, error)
- func (that *KRedisCluster) Type(key string) (string, error)
- type RedisMessage
- type RedisMessagePackConstraints
- type RedisRecord
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnSubscribe = errors.New("func UnSubscribe be called") ErrChannelClosed = errors.New("channel be closed") )
Functions ¶
func MatchFilter ¶
Types ¶
type KRedis ¶
func (*KRedis) JsonDel ¶ added in v0.4.2
JsonDel 封装了 Redis JSON.DEL 命令。 key: Redis 中的键名。 path: 可选的 JSON Path。如果为空字符串,则删除整个 JSON 文档。 返回值:被删除的 JSON 值数量。如果键或路径不存在,通常返回 0。
func (*KRedis) JsonGet ¶ added in v0.4.2
JsonGet 封装了 Redis JSON.GET 命令,并直接返回原始的 JSON 字符串。 调用方将负责对返回的字符串进行反序列化。 key: Redis 中的键名。 paths: 可选的 JSON Path 参数。如果没有提供,则获取整个 JSON 文档。 返回值:JSON 字符串。如果键或路径不存在,或结果为空,则返回空字符串和 nil 错误。
func (*KRedis) JsonMerge ¶ added in v0.4.2
JsonMerge 封装了 Redis JSON.MERGE 命令。 该命令会将 Go 值序列化为 JSON 并与现有值合并。如果路径不存在,则创建新字段。 key: Redis 中的键名。 path: JSON Path,指定要合并的位置。 value: 要存储的 Go 值,将被序列化为 JSON 并与现有值合并。 返回值:如果操作成功则返回 nil,否则返回错误。
func (*KRedis) JsonObjKeys ¶ added in v0.4.2
JsonObjKeys 封装了 Redis JSON.OBJKEYS 命令。 key: Redis 中的键名。 path: 可选的 JSON Path。如果为空字符串,则返回根对象的键。 返回值:一个包含对象键的字符串切片。如果键、路径不存在或路径对应的不是对象,则返回 nil 切片和 nil 错误。
func (*KRedis) JsonObjLen ¶ added in v0.4.2
OBJLEN 获取JSON 对象中键的数量,如果匹配的 JSON 值不是对象,则为 -1 key: Redis 中的键名。 path: 可选的 JSON Path。如果为空字符串,则返回根对象的键。 返回值:一个包含对象键的字符串切片。如果键、路径不存在或路径对应的不是对象,则返回 nil 切片和 nil 错误。
func (*KRedis) JsonSet ¶ added in v0.4.2
JsonSet 封装了 Redis JSON.SET 命令。 它会将 Go 值自动序列化为 JSON 字符串并存储。 key: Redis 中的键名。 path: JSON Path。 value: 要存储的 Go 值,将被序列化为 JSON。 返回值:如果操作成功则返回 nil,否则返回错误。
func (*KRedis) JsonType ¶ added in v0.4.2
JsonType 封装了 Redis JSON.TYPE 命令。 key: Redis 中的键名。 path: 可选的 JSON Path。如果为空字符串,则返回根路径的类型; 不支持同时指定多个路径。 返回值:一个包含 JSON 值类型的字符串切片。如果键或路径不存在,则返回 nil 切片和 nil 错误。
func (*KRedis) PSubscribe ¶
func (mr *KRedis) PSubscribe(timeout int, callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, topic支持通配符, timeout 设置轮询超时时间, 单位ms; callback为接收消息的回调函数; topics为需要订阅的topic
func (*KRedis) PSubscribeLow ¶ added in v0.4.11
func (mr *KRedis) PSubscribeLow(callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, 底层API, 最好使用Subscribe替代
func (*KRedis) PSubscribeWithChanSize ¶
func (mr *KRedis) PSubscribeWithChanSize(timeout int, chanSize int, callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, topic支持通配符, timeout 设置轮询超时时间, 单位ms; chanSize 最大允许队列大小, 如果< 1, 则为1; callback为接收消息的回调函数; topics为需要订阅的topic
func (*KRedis) PublishArray ¶ added in v0.5.9
func (that *KRedis) PublishArray(messages []*RedisMessage) []error
使用pipeline 向指定topic发布多条消息
func (*KRedis) PublishArrayWithCtx ¶ added in v0.5.9
func (that *KRedis) PublishArrayWithCtx(ctx *kcontext.ContextNode, messages []*RedisMessage) []error
使用pipeline 向指定topic发布多条消息
func (*KRedis) RestoreReplace ¶
func (*KRedis) SDiffStore ¶
func (*KRedis) SInterStore ¶
func (*KRedis) SUnionStore ¶
func (*KRedis) Scan ¶
func (mr *KRedis) Scan(limit int, aboutTypes []string, ignoreKeys []string, includeKeys []string, needDel bool, logf klogger.AppLogFuncWithTag) ([]*RedisRecord, error)
func (*KRedis) ScanMatch ¶
func (mr *KRedis) ScanMatch(limit int, aboutTypes []string, ignoreKeys []string, includeKeys []string, needDel bool, logf klogger.AppLogFuncWithTag) ([]*RedisRecord, error)
func (*KRedis) Subscribe ¶
func (mr *KRedis) Subscribe(timeout int, callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, timeout 设置轮询超时时间, 单位ms; callback为接收消息的回调函数; topics为需要订阅的topic
func (*KRedis) SubscribeLow ¶
func (mr *KRedis) SubscribeLow(callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, 底层API, 最好使用Subscribe替代
func (*KRedis) SubscribeWithoutTimeout ¶
func (mr *KRedis) SubscribeWithoutTimeout(callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息
func (*KRedis) SyncPSubscribe ¶ added in v0.4.12
func (mr *KRedis) SyncPSubscribe(timeout int, callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, topic支持通配符, timeout 设置轮询超时时间, 单位ms; callback为接收消息的回调函数; topics为需要订阅的topic
func (*KRedis) SyncPSubscribeLow ¶ added in v0.4.12
func (mr *KRedis) SyncPSubscribeLow(callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, 底层API, 最好使用Subscribe替代
func (*KRedis) SyncPSubscribeWithChanSize ¶ added in v0.4.12
func (mr *KRedis) SyncPSubscribeWithChanSize(timeout int, chanSize int, callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, topic支持通配符, timeout 设置轮询超时时间, 单位ms; chanSize 最大允许队列大小, 如果< 1, 则为1; callback为接收消息的回调函数; topics为需要订阅的topic
func (*KRedis) SyncSubscribe ¶ added in v0.4.12
func (mr *KRedis) SyncSubscribe(timeout int, callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, timeout 设置轮询超时时间, 单位ms; callback为接收消息的回调函数; topics为需要订阅的topic
func (*KRedis) SyncSubscribeLow ¶ added in v0.4.12
func (mr *KRedis) SyncSubscribeLow(callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, 底层API, 最好使用Subscribe替代
type KRedisClient ¶ added in v0.5.4
type KRedisClient interface {
KRedis | KRedisCluster
}
type KRedisCluster ¶ added in v0.5.4
type KRedisCluster struct {
Client *redisHd.ClusterClient
// contains filtered or unexported fields
}
func NewKRedisCluster ¶ added in v0.5.4
func NewKRedisCluster(ctx *kcontext.ContextNode, addrs []string, user string, password string, dbNum int) *KRedisCluster
func (*KRedisCluster) Del ¶ added in v0.5.4
func (that *KRedisCluster) Del(keys ...string) (int64, error)
删除一批key
func (*KRedisCluster) Do ¶ added in v0.5.4
func (that *KRedisCluster) Do(args ...any) (any, error)
执行指令
func (*KRedisCluster) Dump ¶ added in v0.5.4
func (that *KRedisCluster) Dump(key string) (string, error)
func (*KRedisCluster) Exist ¶ added in v0.5.4
func (that *KRedisCluster) Exist(key string) (bool, error)
判断某个key是否存在
func (*KRedisCluster) Expire ¶ added in v0.5.4
func (that *KRedisCluster) Expire(key string, expiration time.Duration) bool
func (*KRedisCluster) ExpireAt ¶ added in v0.5.4
func (that *KRedisCluster) ExpireAt(key string, tm time.Time) bool
func (*KRedisCluster) Get ¶ added in v0.5.4
func (that *KRedisCluster) Get(key string) (any, error)
获取一个key的值
func (*KRedisCluster) HDel ¶ added in v0.5.4
func (that *KRedisCluster) HDel(key string, fields ...string) error
删除一个key的hash字段的值列表
func (*KRedisCluster) HExists ¶ added in v0.5.4
func (that *KRedisCluster) HExists(key string, field string) (bool, error)
判断一个key的hash字段是否存在
func (*KRedisCluster) HGet ¶ added in v0.5.4
func (that *KRedisCluster) HGet(key string, field string) (any, error)
获取一个key的hash字段的值
func (*KRedisCluster) HGetAll ¶ added in v0.5.4
func (that *KRedisCluster) HGetAll(key string) (map[string]string, error)
获取一个key的hash字段的值列表
func (*KRedisCluster) HLen ¶ added in v0.5.4
func (that *KRedisCluster) HLen(key string) (int64, error)
获取一个key的hash字段的数量
func (*KRedisCluster) HMGet ¶ added in v0.5.4
func (that *KRedisCluster) HMGet(key string, fields ...string) ([]any, error)
获取一个key的hash字段的值列表
func (*KRedisCluster) HMSet ¶ added in v0.5.4
func (that *KRedisCluster) HMSet(key string, fields map[string]any) error
设置一个key的hash字段的值列表, 如果不存在则创建
func (*KRedisCluster) HSet ¶ added in v0.5.4
func (that *KRedisCluster) HSet(key string, field string, value any) error
设置一个key的hash字段的值
func (*KRedisCluster) HSetAll ¶ added in v0.5.4
func (that *KRedisCluster) HSetAll(key string, fields map[string]any) error
设置一个key的hash字段的值列表
func (*KRedisCluster) JsonDel ¶ added in v0.5.4
func (that *KRedisCluster) JsonDel(key string, path string) (int64, error)
JsonDel 封装了 Redis JSON.DEL 命令。 key: Redis 中的键名。 path: 可选的 JSON Path。如果为空字符串,则删除整个 JSON 文档。 返回值:被删除的 JSON 值数量。如果键或路径不存在,通常返回 0。
func (*KRedisCluster) JsonGet ¶ added in v0.5.4
func (that *KRedisCluster) JsonGet(key string, paths ...string) (string, error)
JsonGet 封装了 Redis JSON.GET 命令,并直接返回原始的 JSON 字符串。 调用方将负责对返回的字符串进行反序列化。 key: Redis 中的键名。 paths: 可选的 JSON Path 参数。如果没有提供,则获取整个 JSON 文档。 返回值:JSON 字符串。如果键或路径不存在,或结果为空,则返回空字符串和 nil 错误。
func (*KRedisCluster) JsonMerge ¶ added in v0.5.4
func (that *KRedisCluster) JsonMerge(key string, path string, value string) error
JsonMerge 封装了 Redis JSON.MERGE 命令。 该命令会将 Go 值序列化为 JSON 并与现有值合并。如果路径不存在,则创建新字段。 key: Redis 中的键名。 path: JSON Path,指定要合并的位置。 value: 要存储的 Go 值,将被序列化为 JSON 并与现有值合并。 返回值:如果操作成功则返回 nil,否则返回错误。
func (*KRedisCluster) JsonObjKeys ¶ added in v0.5.4
func (that *KRedisCluster) JsonObjKeys(key string, path string) ([]string, error)
JsonObjKeys 封装了 Redis JSON.OBJKEYS 命令。 key: Redis 中的键名。 path: 可选的 JSON Path。如果为空字符串,则返回根对象的键。 返回值:一个包含对象键的字符串切片。如果键、路径不存在或路径对应的不是对象,则返回 nil 切片和 nil 错误。
func (*KRedisCluster) JsonObjLen ¶ added in v0.5.4
func (that *KRedisCluster) JsonObjLen(key string, path string) ([]int64, error)
OBJLEN 获取JSON 对象中键的数量,如果匹配的 JSON 值不是对象,则为 -1 key: Redis 中的键名。 path: 可选的 JSON Path。如果为空字符串,则返回根对象的键。 返回值:一个包含对象键的字符串切片。如果键、路径不存在或路径对应的不是对象,则返回 nil 切片和 nil 错误。
func (*KRedisCluster) JsonSet ¶ added in v0.5.4
func (that *KRedisCluster) JsonSet(key string, path string, value string) error
JsonSet 封装了 Redis JSON.SET 命令。 它会将 Go 值自动序列化为 JSON 字符串并存储。 key: Redis 中的键名。 path: JSON Path。 value: 要存储的 Go 值,将被序列化为 JSON。 返回值:如果操作成功则返回 nil,否则返回错误。
func (*KRedisCluster) JsonType ¶ added in v0.5.4
func (that *KRedisCluster) JsonType(key string, path string) ([]string, error)
JsonType 封装了 Redis JSON.TYPE 命令。 key: Redis 中的键名。 path: 可选的 JSON Path。如果为空字符串,则返回根路径的类型; 不支持同时指定多个路径。 返回值:一个包含 JSON 值类型的字符串切片。如果键或路径不存在,则返回 nil 切片和 nil 错误。
func (*KRedisCluster) LIndex ¶ added in v0.5.4
func (that *KRedisCluster) LIndex(key string, index int64) (string, error)
根据索引坐标,查询列表中的数据
func (*KRedisCluster) LInsert ¶ added in v0.5.4
func (that *KRedisCluster) LInsert(key string, position string, pivot any, value any) (int64, error)
在指定位置插入数据,在头部插入用"before",尾部插入用"after"
func (*KRedisCluster) LLen ¶ added in v0.5.4
func (that *KRedisCluster) LLen(key string) (int64, error)
返回列表的大小
func (*KRedisCluster) LPop ¶ added in v0.5.4
func (that *KRedisCluster) LPop(key string) (string, error)
从列表左边弹出数据
func (*KRedisCluster) LPush ¶ added in v0.5.4
func (that *KRedisCluster) LPush(key string, values ...any) (int64, error)
从列表左边插入数据
func (*KRedisCluster) LPushX ¶ added in v0.5.4
func (that *KRedisCluster) LPushX(key string, values ...any) (int64, error)
从列表左边插入数据, 如果不存在则不插入数据
func (*KRedisCluster) LSet ¶ added in v0.5.4
func (that *KRedisCluster) LSet(key string, index int64, value any) error
func (*KRedisCluster) LTrim ¶ added in v0.5.4
func (that *KRedisCluster) LTrim(key string, start int64, stop int64) error
func (*KRedisCluster) PSubscribe ¶ added in v0.5.4
func (that *KRedisCluster) PSubscribe(timeout int, callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, topic支持通配符, timeout 设置轮询超时时间, 单位ms; callback为接收消息的回调函数; topics为需要订阅的topic
func (*KRedisCluster) PSubscribeLow ¶ added in v0.5.4
func (that *KRedisCluster) PSubscribeLow(callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, 底层API, 最好使用Subscribe替代
func (*KRedisCluster) PSubscribeWithChanSize ¶ added in v0.5.4
func (that *KRedisCluster) PSubscribeWithChanSize(timeout int, chanSize int, callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, topic支持通配符, timeout 设置轮询超时时间, 单位ms; chanSize 最大允许队列大小, 如果< 1, 则为1; callback为接收消息的回调函数; topics为需要订阅的topic
func (*KRedisCluster) PTTL ¶ added in v0.5.4
func (that *KRedisCluster) PTTL(key string) (time.Duration, error)
返回一个Key的过期时间, 单位为毫秒
func (*KRedisCluster) Pipeline ¶ added in v0.5.4
func (that *KRedisCluster) Pipeline() redisHd.Pipeliner
func (*KRedisCluster) Publish ¶ added in v0.5.4
func (that *KRedisCluster) Publish(topic string, payload any) error
向指定topic发布消息
func (*KRedisCluster) PublishArray ¶ added in v0.5.9
func (that *KRedisCluster) PublishArray(messages []*RedisMessage) []error
使用pipeline 向指定topic发布多条消息
func (*KRedisCluster) PublishArrayWithCtx ¶ added in v0.5.9
func (that *KRedisCluster) PublishArrayWithCtx(ctx *kcontext.ContextNode, messages []*RedisMessage) []error
使用pipeline 向指定topic发布多条消息
func (*KRedisCluster) RPop ¶ added in v0.5.4
func (that *KRedisCluster) RPop(key string) (string, error)
从列表右边弹出数据
func (*KRedisCluster) RPush ¶ added in v0.5.4
func (that *KRedisCluster) RPush(key string, values ...any) (int64, error)
从列表右边插入数据
func (*KRedisCluster) RPushX ¶ added in v0.5.4
func (that *KRedisCluster) RPushX(key string, values ...any) (int64, error)
从列表右边插入数据, 如果不存在则不插入数据
func (*KRedisCluster) RestoreReplace ¶ added in v0.5.4
func (*KRedisCluster) SAdd ¶ added in v0.5.4
func (that *KRedisCluster) SAdd(key string, members ...any) (int64, error)
func (*KRedisCluster) SCard ¶ added in v0.5.4
func (that *KRedisCluster) SCard(key string) (int64, error)
func (*KRedisCluster) SDiff ¶ added in v0.5.4
func (that *KRedisCluster) SDiff(keys ...string) ([]string, error)
func (*KRedisCluster) SDiffStore ¶ added in v0.5.4
func (that *KRedisCluster) SDiffStore(destKey string, keys ...string) (int64, error)
func (*KRedisCluster) SInter ¶ added in v0.5.4
func (that *KRedisCluster) SInter(keys ...string) ([]string, error)
func (*KRedisCluster) SInterStore ¶ added in v0.5.4
func (that *KRedisCluster) SInterStore(destKey string, keys ...string) (int64, error)
func (*KRedisCluster) SIsMember ¶ added in v0.5.4
func (that *KRedisCluster) SIsMember(key string, member any) (bool, error)
func (*KRedisCluster) SMembers ¶ added in v0.5.4
func (that *KRedisCluster) SMembers(key string) ([]string, error)
func (*KRedisCluster) SMove ¶ added in v0.5.4
func (that *KRedisCluster) SMove(source, destination string, member any) (bool, error)
func (*KRedisCluster) SPop ¶ added in v0.5.4
func (that *KRedisCluster) SPop(key string) (string, error)
func (*KRedisCluster) SPopN ¶ added in v0.5.4
func (that *KRedisCluster) SPopN(key string, count int64) ([]string, error)
func (*KRedisCluster) SRandMember ¶ added in v0.5.4
func (that *KRedisCluster) SRandMember(key string) (string, error)
func (*KRedisCluster) SRem ¶ added in v0.5.4
func (that *KRedisCluster) SRem(key string, members ...any) (int64, error)
func (*KRedisCluster) SUnion ¶ added in v0.5.4
func (that *KRedisCluster) SUnion(keys ...string) ([]string, error)
func (*KRedisCluster) SUnionStore ¶ added in v0.5.4
func (that *KRedisCluster) SUnionStore(destKey string, keys ...string) (int64, error)
func (*KRedisCluster) Scan ¶ added in v0.5.4
func (that *KRedisCluster) Scan(limit int, aboutTypes []string, ignoreKeys []string, includeKeys []string, needDel bool, logf klogger.AppLogFuncWithTag) ([]*RedisRecord, error)
func (*KRedisCluster) ScanMatch ¶ added in v0.5.4
func (that *KRedisCluster) ScanMatch(limit int, aboutTypes []string, ignoreKeys []string, includeKeys []string, needDel bool, logf klogger.AppLogFuncWithTag) ([]*RedisRecord, error)
func (*KRedisCluster) Stop ¶ added in v0.5.4
func (that *KRedisCluster) Stop()
func (*KRedisCluster) Subscribe ¶ added in v0.5.4
func (that *KRedisCluster) Subscribe(timeout int, callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, timeout 设置轮询超时时间, 单位ms; callback为接收消息的回调函数; topics为需要订阅的topic
func (*KRedisCluster) SubscribeLow ¶ added in v0.5.4
func (that *KRedisCluster) SubscribeLow(callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, 底层API, 最好使用Subscribe替代
func (*KRedisCluster) SubscribeWithoutTimeout ¶ added in v0.5.4
func (that *KRedisCluster) SubscribeWithoutTimeout(callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息
func (*KRedisCluster) SyncPSubscribe ¶ added in v0.5.4
func (that *KRedisCluster) SyncPSubscribe(timeout int, callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, topic支持通配符, timeout 设置轮询超时时间, 单位ms; callback为接收消息的回调函数; topics为需要订阅的topic
func (*KRedisCluster) SyncPSubscribeLow ¶ added in v0.5.4
func (that *KRedisCluster) SyncPSubscribeLow(callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, 底层API, 最好使用Subscribe替代
func (*KRedisCluster) SyncPSubscribeWithChanSize ¶ added in v0.5.4
func (that *KRedisCluster) SyncPSubscribeWithChanSize(timeout int, chanSize int, callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, topic支持通配符, timeout 设置轮询超时时间, 单位ms; chanSize 最大允许队列大小, 如果< 1, 则为1; callback为接收消息的回调函数; topics为需要订阅的topic
func (*KRedisCluster) SyncSubscribe ¶ added in v0.5.4
func (that *KRedisCluster) SyncSubscribe(timeout int, callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, timeout 设置轮询超时时间, 单位ms; callback为接收消息的回调函数; topics为需要订阅的topic
func (*KRedisCluster) SyncSubscribeLow ¶ added in v0.5.4
func (that *KRedisCluster) SyncSubscribeLow(callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息, 底层API, 最好使用Subscribe替代
func (*KRedisCluster) SyncSubscribeWithoutTimeout ¶ added in v0.5.4
func (that *KRedisCluster) SyncSubscribeWithoutTimeout(callback func(err error, topic string, payload any), topics ...string)
从指定topic订阅消息
type RedisMessage ¶
type RedisMessagePackConstraints ¶
type RedisMessagePackConstraints interface {
RedisRecord | RedisMessage
}