Get data by pattern #1

Merged
milano15662 merged 4 commits from get-data-by-pattern into master 2022-03-25 10:10:05 +00:00
1 changed files with 33 additions and 0 deletions
Showing only changes of commit 562d8c6f64 - Show all commits

View File

@ -0,0 +1,33 @@
package redisdb
import "context"
// GetWithPrefixPattern ...
func GetWithPrefixPattern(pattern string, limit int64) (keys []string, values []string) {
// Init
keys = make([]string, 0)
values = make([]string, 0)
var (
ctx = context.Background()
cursor uint64
err error
)
keys, cursor, err = rdb.Scan(ctx, cursor, pattern, limit).Result()
if err != nil {
return
}
if len(keys) == 0 {
return
}
// Get value
for _, key := range keys {
value := GetValueByKey(ctx, key)
values = append(values, value)
}
return
}