Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scan method #229

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cache/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ func (r *Redis) MGet(ctx context.Context, key ...string) ([][]byte, error) {
return result, nil
}

// Scan return keys by pattern
func (r *Redis) Scan(ctx context.Context, cursor uint64, match string, count int64) ([]string, error) {
iter := r.client.Scan(ctx, cursor, match, count).Iterator()

res := make([]string, 0)
for iter.Next(ctx) {
res = append(res, iter.Val())
}

return res, iter.Err()
}

func (r *Redis) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error {
data, err := json.Marshal(value)
if err != nil {
Expand Down