mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Avoid unnecessary re-reading of file context when caching is enabled
This commit is contained in:
parent
7d702e8332
commit
a1251371d7
@ -192,8 +192,10 @@ LocalFileSystem.prototype._set = function(scope, key, value, callback) {
|
||||
LocalFileSystem.prototype.set = function(scope, key, value, callback) {
|
||||
if (this.cache) {
|
||||
this.cache.set(scope,key,value,callback);
|
||||
this._set(scope,key,value, function(err) {
|
||||
// TODO: log any errors
|
||||
// With cache enabled, no need to re-read the file prior to writing.
|
||||
var newContext = this.cache._export()[scope];
|
||||
var storagePath = getStoragePath(this.storageBaseDir ,scope);
|
||||
fs.outputFile(storagePath + ".json", JSON.stringify(newContext, undefined, 4), "utf8").catch(function(err) {
|
||||
});
|
||||
} else {
|
||||
this._set(scope,key,value,callback);
|
||||
|
@ -109,6 +109,11 @@ Memory.prototype.clean = function(activeNodes){
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
Memory.prototype._export = function() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
|
||||
module.exports = function(config){
|
||||
return new Memory(config);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user