@@ -29,14 +29,14 @@ class PersistentNodeCache extends node_cache_1.default {
2929 constructor ( cacheName , period , dir , opts ) {
3030 super ( opts ) ;
3131 this . cacheName = cacheName ;
32- this . interval = setInterval ( ( ) => { this . saveToDisk ( ) ; } , period ) ;
32+ this . interval = setInterval ( ( ) => { this . saveToDisk ( ) ; } , period || 1000 ) ;
3333 this . emitter = new events_1 . EventEmitter ( ) ;
3434 this . flushingToDisk = false ;
3535 if ( dir === null || dir === void 0 ? void 0 : dir . endsWith ( '/' ) ) {
3636 dir = dir . slice ( 0 , - 1 ) ;
3737 }
38- this . backupFilePath = ( dir || os_1 . default . homedir ( ) ) + `/${ cacheName } .backup` ;
39- this . appendFilePath = ( dir || os_1 . default . homedir ( ) ) + `/${ cacheName } .append` ;
38+ this . backupFilePath = ( dir || os_1 . default . homedir ( ) ) + `/${ this . cacheName } .backup` ;
39+ this . appendFilePath = ( dir || os_1 . default . homedir ( ) ) + `/${ this . cacheName } .append` ;
4040 fs_1 . default . writeFileSync ( this . appendFilePath , '' ) ;
4141 super . on ( "expired" , ( key , _ ) => { this . appendExpiredEvent ( key ) ; } ) ;
4242 }
@@ -186,11 +186,6 @@ class PersistentNodeCache extends node_cache_1.default {
186186 let bf = Buffer . from ( JSON . stringify ( data ) ) ;
187187 fs_1 . default . writeFileSync ( this . backupFilePath , bf ) ;
188188 fs_1 . default . writeFileSync ( this . appendFilePath , '' ) ;
189- // fs.write(this.appendFileDescriptor, '', (writeErr, written, buffer) => {
190- // if (writeErr) {
191- // console.error('Error writing to file:', writeErr);
192- // }
193- // });
194189 this . appendFileDescriptor . close ( ) ;
195190 }
196191 catch ( err ) {
@@ -220,13 +215,8 @@ class PersistentNodeCache extends node_cache_1.default {
220215 this . appendFileDescriptor = fd ;
221216 fs_1 . default . write ( fd , data , 0 , data . length , null , ( writeErr , written , buffer ) => {
222217 if ( writeErr ) {
223- console . error ( 'Error witing to file:' , writeErr ) ;
218+ console . error ( 'Error writing to file:' , writeErr ) ;
224219 }
225- // fs.close(fd, (closeErr) => {
226- // if(closeErr) {
227- // console.error('Error closing file:', closeErr);
228- // }
229- // });
230220 } ) ;
231221 } ) ;
232222 }
0 commit comments