Skip to content

Commit e2d0bd5

Browse files
fix: support invalidation on redis invalid references (#97)
1 parent 6270cd4 commit e2d0bd5

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/storage/redis.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ class StorageRedis extends StorageInterface {
214214
const removed = []
215215
for (let i = 0; i < keys.length; i++) {
216216
const key0 = keys[i][1]
217+
if (!key0) { continue }
217218
this.log.debug({ msg: 'acd/storage/redis._invalidateReferences got keys to be invalidated', keys: key0 })
218219
for (let j = 0; j < key0.length; j++) {
219220
const key1 = key0[j]

test/storage-redis.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,13 @@ test('storage redis', async (t) => {
561561

562562
t.doesNotThrow(() => storage.invalidate(['pizzers']))
563563
})
564+
565+
test('should not throw invalidating non-existing references', async (t) => {
566+
const storage = createStorage('redis', { client: redisClient, invalidation: true })
567+
await redisClient.set('r:model:1', 'value')
568+
569+
t.doesNotThrow(() => storage.invalidate(['model:1', 'model:2']))
570+
})
564571
})
565572

566573
test('clear', async (t) => {

0 commit comments

Comments
 (0)