Skip to content

Commit cc8d25c

Browse files
committed
feat: log when flush to disk
1 parent 42488ab commit cc8d25c

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

electron/main/cache/disk-cache.service.ts

+15-10
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,24 @@ export class DiskCacheServiceImpl extends AbstractCacheService {
5454

5555
private createDebouncedWriteToDisk(): DebouncedFunc<() => Promise<void>> {
5656
return debounce(async () => {
57-
const { filepath } = this.options;
58-
try {
59-
const cache = await this.delegate.readCache();
60-
await fs.writeJson(filepath, cache);
61-
} catch (error) {
62-
logger.error('error writing cache to disk', {
63-
filepath,
64-
error,
65-
});
66-
}
57+
await this.writeToDiskNow();
6758
}, 1000);
6859
}
6960

61+
private async writeToDiskNow(): Promise<void> {
62+
const { filepath } = this.options;
63+
try {
64+
const cache = await this.delegate.readCache();
65+
await fs.writeJson(filepath, cache);
66+
logger.debug('wrote cache to disk');
67+
} catch (error) {
68+
logger.error('error writing cache to disk', {
69+
filepath,
70+
error,
71+
});
72+
}
73+
}
74+
7075
public async set<T>(key: string, item: T): Promise<void> {
7176
await this.delegate.set(key, item);
7277
await this.writeToDisk();

0 commit comments

Comments
 (0)