1 Star 0 Fork 0

carlmax_my/console-core-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
keys.go 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
carlmax_my 提交于 2024-12-02 21:32 . init project
package redis
import "context"
const SCAN_COUNT = 10000
func (c *cacheRepo) GetScanKeys(pattern string) (result []string, err error) {
result = make([]string, 0)
ctx := context.Background()
var cursor uint64
var keys []string
for {
if keys, cursor, err = c.client.Scan(ctx, cursor, pattern, SCAN_COUNT).Result(); err != nil {
break
}
if len(keys) > 0 {
result = append(result, keys...)
}
if cursor == 0 {
break
}
}
return
}
func (c *cacheRepo) GetSScanKeys(key string, pattern string) (result []string, err error) {
result = make([]string, 0)
ctx := context.Background()
var cursor uint64
var keys []string
for {
if keys, cursor, err = c.client.SScan(ctx, key, cursor, pattern, SCAN_COUNT).Result(); err != nil {
break
}
if len(keys) > 0 {
result = append(result, keys...)
}
if cursor == 0 {
break
}
}
return
}
func (c *cacheRepo) GetHScanKeys(key string, pattern string) (result []string, err error) {
result = make([]string, 0)
ctx := context.Background()
var cursor uint64
var keys []string
for {
if keys, cursor, err = c.client.HScan(ctx, key, cursor, pattern, SCAN_COUNT).Result(); err != nil {
break
}
if len(keys) > 0 {
result = append(result, keys...)
}
if cursor == 0 {
break
}
}
return
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/carlmax_my/console-core-go.git
git@gitee.com:carlmax_my/console-core-go.git
carlmax_my
console-core-go
console-core-go
v0.0.5

搜索帮助

0d507c66 1850385 C8b1a773 1850385