feat: 在storage-manager添加keys方法

This commit is contained in:
layhuts
2026-05-09 10:58:41 +08:00
parent 329fa68207
commit 8ce773f264

View File

@@ -71,6 +71,18 @@ class StorageManager {
return raw.value;
}
/**
* 获取当前前缀下的所有存储键(已去除前缀部分)
*/
async keys(): Promise<string[]> {
const allKeys = await this.driver.keys();
const fullPrefix = this.prefix ? `${this.prefix}-` : '';
if (!fullPrefix) return allKeys;
return allKeys
.filter((key) => key.startsWith(fullPrefix))
.map((key) => key.slice(fullPrefix.length));
}
/**
* 移除存储项
* @param key 键