scan. glob to regex (#14063)

* scan. glob to regex

* lint
This commit is contained in:
Barış Uşaklı
2026-03-05 16:01:03 -05:00
committed by GitHub
parent 5d1a8a11fd
commit 7d50baecf0
6 changed files with 44 additions and 30 deletions

View File

@@ -86,6 +86,27 @@ describe('Key methods', () => {
assert(data.includes('ip:124:uid'));
assert(data.includes('ip:1:uid'));
});
it('should scan keys for specific glob pattern', async () => {
const keys = [
'tid:00000b86-a333-45ee-ba88-17e78aa6c814:recipients',
'tid:00001fa5-61e1-4ba5-ac22-572ab98eb76f:recipients',
'tid:00002ce3-203d-4b14-a201-b3d021f462a5:recipients',
'other:123:stuff',
'tid:999:sender',
];
await db.sortedSetAddBulk(keys.map(key => [key, 1, 'a']));
const data = await db.scan({ match: 'tid:*:recipients' });
assert.equal(data.length, 3, 'Should have found exactly 3 recipient keys');
assert(data.includes('tid:00000b86-a333-45ee-ba88-17e78aa6c814:recipients'));
assert(data.includes('tid:00001fa5-61e1-4ba5-ac22-572ab98eb76f:recipients'));
assert(data.includes('tid:00002ce3-203d-4b14-a201-b3d021f462a5:recipients'));
assert(!data.includes('other:123:stuff'), 'Should not include unrelated keys');
assert(!data.includes('tid:999:sender'), 'Should not include sender keys');
});
});
it('should delete a key without error', (done) => {