chore: keys function requires sortKey, add allKeys
This commit is contained in:
2
src/cache/SortKeyCache.ts
vendored
2
src/cache/SortKeyCache.ts
vendored
@@ -66,7 +66,7 @@ export interface SortKeyCache<V> {
|
||||
/**
|
||||
* Returns keys for a specified range
|
||||
*/
|
||||
keys(sortKey?: string, options?: SortKeyCacheRangeOptions): Promise<string[]>;
|
||||
keys(sortKey: string, options?: SortKeyCacheRangeOptions): Promise<string[]>;
|
||||
|
||||
/**
|
||||
* Returns a key value map for a specified range
|
||||
|
||||
10
src/cache/impl/LevelDbCache.ts
vendored
10
src/cache/impl/LevelDbCache.ts
vendored
@@ -272,7 +272,7 @@ export class LevelDbCache<V> implements SortKeyCache<V> {
|
||||
return lastSortKey == '' ? null : lastSortKey;
|
||||
}
|
||||
|
||||
async keys(sortKey?: string, options?: SortKeyCacheRangeOptions): Promise<string[]> {
|
||||
async keys(sortKey: string, options?: SortKeyCacheRangeOptions): Promise<string[]> {
|
||||
return Array.from((await this.kvMap(sortKey, options)).keys());
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ export class LevelDbCache<V> implements SortKeyCache<V> {
|
||||
entriesStored = 1;
|
||||
}
|
||||
|
||||
const contracts = await this.keys();
|
||||
const contracts = await this.allKeys();
|
||||
for (let i = 0; i < contracts.length; i++) {
|
||||
const contractCache = this.db.sublevel<string, ClientValueWrapper<V>>(contracts[i], this.subLevelOptions);
|
||||
|
||||
@@ -378,4 +378,10 @@ export class LevelDbCache<V> implements SortKeyCache<V> {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private async allKeys(): Promise<string[]> {
|
||||
return (await this.db.keys().all())
|
||||
.filter((k) => k != this.ongoingTransactionMark)
|
||||
.map((k) => this.extractOriginalKey(k));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user