Skip to content

Commit ffb8ea4

Browse files
committed
fix: make FlushByPrefix to public in RedisStore
1 parent 6f6c610 commit ffb8ea4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cache/redis_store.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,19 @@ func (s *RedisStore) Flush() error {
158158
return nil
159159
}
160160

161-
return s.flush()
161+
return s.FlushByPrefix("")
162162
}
163163

164-
func (s *RedisStore) flush() error {
164+
func (s *RedisStore) FlushByPrefix(prefix string) error {
165165
c := s.pool.Get()
166166
defer c.Close()
167167

168168
var err error
169169
iter := 0
170170
keys := []string{}
171-
171+
pattern := s.prefix + prefix + "*"
172172
for {
173-
arr, err := redis.Values(c.Do("SCAN", iter, "MATCH", s.prefix+"*"))
173+
arr, err := redis.Values(c.Do("SCAN", iter, "MATCH", pattern))
174174
if err != nil {
175175
return err
176176
}
@@ -197,6 +197,7 @@ func (s *RedisStore) flush() error {
197197
if err != nil {
198198
return err
199199
}
200+
keysChunk = nil
200201
}
201202
}
202203

@@ -336,6 +337,7 @@ func (s *RedisStore) deleteKeys(referenceKey string) error {
336337
if err != nil {
337338
return err
338339
}
340+
keysChunk = nil
339341
}
340342
}
341343

0 commit comments

Comments
 (0)