Skip to content

Commit c00f16f

Browse files
committed
Fix bug in handling cursor
1 parent 3c880b6 commit c00f16f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

plugin/plugin.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,18 @@ func (p *Plugin) invalidateDML(ctx context.Context, query string) {
268268
// TODO: This is not efficient. We should be able to invalidate the cache
269269
// for a specific key instead of invalidating the entire table.
270270
pipeline := p.RedisClient.Pipeline()
271+
var cursor uint64
271272
for {
272-
scanResult := p.RedisClient.Scan(ctx, 0, table+":*", p.ScanCount)
273+
scanResult := p.RedisClient.Scan(ctx, cursor, table+":*", p.ScanCount)
273274
if scanResult.Err() != nil {
274275
CacheMissesCounter.Inc()
275276
p.Logger.Debug("Failed to scan keys", "error", scanResult.Err())
276277
break
277278
}
278279

279280
// Per each key, delete the cache entry and the table cache key itself.
280-
keys, cursor := scanResult.Val()
281+
var keys []string
282+
keys, cursor = scanResult.Val()
281283
for _, tableKey := range keys {
282284
// Invalidate the cache for the table.
283285
cachedRespnseKey := strings.TrimPrefix(tableKey, table+":")

0 commit comments

Comments
 (0)