Skip to content

Commit eae7f19

Browse files
authored
fix: according to the redis documentation, an iterator must not be considered finished unless it returns a cursor value of 0, even if the returned page has no entries (#749)
1 parent aedbf4b commit eae7f19

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

packages/redis/src/index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,14 @@ class KeyvRedis extends EventEmitter {
7676
const get = this.redis.mget.bind(this.redis);
7777
async function * iterate(curs, pattern) {
7878
const [cursor, keys] = await scan(curs, 'MATCH', pattern);
79-
if (keys.length === 0) {
80-
return;
81-
}
8279

83-
const values = await get(keys);
84-
for (const [i] of keys.entries()) {
85-
const key = keys[i];
86-
const value = values[i];
87-
yield [key, value];
80+
if (keys.length > 0) {
81+
const values = await get(keys);
82+
for (const [i] of keys.entries()) {
83+
const key = keys[i];
84+
const value = values[i];
85+
yield [key, value];
86+
}
8887
}
8988

9089
if (cursor !== '0') {

0 commit comments

Comments
 (0)