diff --git a/get_with_prefix_pattern.go b/get_with_prefix_pattern.go new file mode 100644 index 0000000..a5addab --- /dev/null +++ b/get_with_prefix_pattern.go @@ -0,0 +1,35 @@ +package redisdb + +import ( + "context" +) + +// GetWithPrefixPattern ... +func GetWithPrefixPattern(pattern string) (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, 1000000).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 +}