@ -3,8 +3,17 @@ const fs = require("fs"),
config _path = "./config/caching_dump.json" ,
cache _dump = JSON . parse ( fs . readFileSync ( config _path ) ) ,
cache _dir = "./.cache" ,
cache = { } ; // TODO: Must read from dump again
if ( cache _dump != null && cache _dump [ "last" ] != null ) cache = cache _dump [ "last" ] ;
cache = { } ;
var logger = require ( "winston" ) ;
if ( cache _dump != null && cache _dump [ "last" ] != null ) cache = cache _dump [ "last" ] ; // read the data from the file dump
/ * *
* Sets the logger for logging
* @ param { Winston Logger } newLogger
* /
exports . setLogger = function ( newLogger ) {
logger = newLogger ;
}
/ * *
* Returns the data from files that were cached
@ -56,15 +65,6 @@ exports.cache = function(filename, data) {
} ) ;
} ) ; // write the data asynchronously to the file
} ;
var logger = require ( "winston" ) ;
/ * *
* Sets the logger for logging
* @ param { Winston Logger } newLogger
* /
exports . setLogger = function ( newLogger ) {
logger = newLogger ;
}
/ * *
* Returns if the file is already cached
@ -94,6 +94,6 @@ exports.isCached = function(filename) {
* /
exports . cleanup = function ( ) {
logger . verbose ( "Dumping cache into cache_dump file" ) ;
cache _dump [ "last" ] = cache ;
fs . writeFileSync ( config _path , JSON . stringify ( cache _dump ) ) ;
cache _dump [ "last" ] = cache ; // append the cache to the dump object
fs . writeFileSync ( config _path , JSON . stringify ( cache _dump ) ) ; // write the dump data to the file
}