-
Notifications
You must be signed in to change notification settings - Fork 165
Labels
Description
Environment
[email protected], node v20.9.0
Reproduction
Currently getKeys
and clear
behave differently when they are passed a prefix.
const prefix = 'test';
let keys = await storage.getKeys(prefix);
console.log(keys); // ['test:123', 'test:abc']
await storage.clear(prefix);
keys = await storage.getKeys(prefix);
console.log(keys); // ['test:123', 'test:abc']
clear
seems to ignore the prefix if it is not a mount, while getKeys
finds all keys which begin with the prefix. Since the options are named the same I had assumed they would behave similarly.
Describe the bug
Is this behavior intentional? Currently I'm working around it by individually deleting keys, but it would be nice if clear
also worked.
const prefix = 'test';
let keys = await storage.getKeys(prefix);
console.log(keys); // ['test:123', 'test:abc']
await Promise.all(keys.map((k) => this.storage.removeItem(k)));
keys = await storage.getKeys(prefix);
console.log(keys); // []
Additional context
No response
Logs
No response
pi0, babalugats76, TimGonnet, KuhlTime, MrEraxd and 1 more