Commit cc8d25c 1 parent 42488ab commit cc8d25c Copy full SHA for cc8d25c
File tree 1 file changed +15
-10
lines changed
1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -54,19 +54,24 @@ export class DiskCacheServiceImpl extends AbstractCacheService {
54
54
55
55
private createDebouncedWriteToDisk ( ) : DebouncedFunc < ( ) => Promise < void > > {
56
56
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 ( ) ;
67
58
} , 1000 ) ;
68
59
}
69
60
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
+
70
75
public async set < T > ( key : string , item : T ) : Promise < void > {
71
76
await this . delegate . set ( key , item ) ;
72
77
await this . writeToDisk ( ) ;
You can’t perform that action at this time.
0 commit comments