fix: 加上 - 分隔符来避免跨前缀误匹配
parent
1f584ff0c9
commit
9667232684
|
|
@ -27,7 +27,8 @@ class StorageManager {
|
||||||
*/
|
*/
|
||||||
async clear(): Promise<void> {
|
async clear(): Promise<void> {
|
||||||
const allKeys = await this.driver.keys();
|
const allKeys = await this.driver.keys();
|
||||||
const prefixedKeys = allKeys.filter((key) => key.startsWith(this.prefix));
|
const fullPrefix = this.prefix ? `${this.prefix}-` : '';
|
||||||
|
const prefixedKeys = allKeys.filter((key) => key.startsWith(fullPrefix));
|
||||||
await Promise.all(prefixedKeys.map((key) => this.driver.removeItem(key)));
|
await Promise.all(prefixedKeys.map((key) => this.driver.removeItem(key)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,7 +37,8 @@ class StorageManager {
|
||||||
*/
|
*/
|
||||||
async clearExpiredItems(): Promise<void> {
|
async clearExpiredItems(): Promise<void> {
|
||||||
const allKeys = await this.driver.keys();
|
const allKeys = await this.driver.keys();
|
||||||
const prefixedKeys = allKeys.filter((key) => key.startsWith(this.prefix));
|
const fullPrefix = this.prefix ? `${this.prefix}-` : '';
|
||||||
|
const prefixedKeys = allKeys.filter((key) => key.startsWith(fullPrefix));
|
||||||
|
|
||||||
for (const fullKey of prefixedKeys) {
|
for (const fullKey of prefixedKeys) {
|
||||||
const raw = await this.driver.getItem<StorageItem<unknown>>(fullKey);
|
const raw = await this.driver.getItem<StorageItem<unknown>>(fullKey);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue