Skip to content

Commit 142deb1

Browse files
committed
Update cache snapshot.
1 parent 04771e9 commit 142deb1

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

changes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
- added: `Image.watermark(filename, [x], [y], [width], [height])` creates a watermark
55
- added: hidden hack `res.noCompress = true` disables compilation of `.js` or `.css`
66
- added: `RESTBuilder` for creating REST requests (more in docs)
7-
- added: new config item `default-interval-cache-snapshot` - to prevent cache when the framework is restarted
7+
- added: new config item `allow-cache-snapshot` - to prevent cache when the framework is restarted
88

99
- updated: `SINGLETON(name, [def = {}])` about `def` argument
1010
- updated: `debug.js` adds timestamps

index.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ function Framework() {
547547
'allow-performance': false,
548548
'allow-custom-titles': false,
549549
'allow-compatibility': false,
550+
'allow-cache-snapshot': false,
550551
'disable-strict-server-certificate-validation': true,
551552
'disable-clear-temporary-directory': false,
552553

@@ -556,8 +557,7 @@ function Framework() {
556557
'default-interval-clear-cache': 7,
557558
'default-interval-precompile-views': 61,
558559
'default-interval-websocket-ping': 3,
559-
'default-interval-clear-dnscache': 120,
560-
'default-interval-cache-snapshot': 0
560+
'default-interval-clear-dnscache': 120
561561
};
562562

563563
this.global = {};
@@ -8373,7 +8373,6 @@ Framework.prototype._configure = function(arr, rewrite) {
83738373
case 'default-interval-websocket-ping':
83748374
case 'default-maximum-file-descriptors':
83758375
case 'default-interval-clear-dnscache':
8376-
case 'default-interval-cache-snapshot':
83778376
obj[name] = framework_utils.parseInt(value);
83788377
break;
83798378

@@ -8402,6 +8401,7 @@ Framework.prototype._configure = function(arr, rewrite) {
84028401
case 'disable-strict-server-certificate-validation':
84038402
case 'disable-clear-temporary-directory':
84048403
case 'trace':
8404+
case 'allow-cache-snapshot':
84058405
obj[name] = value.toLowerCase() === 'true' || value === '1' || value === 'on';
84068406
break;
84078407

@@ -9189,7 +9189,7 @@ function FrameworkCache() {
91899189
FrameworkCache.prototype.init = function() {
91909190
clearInterval(this.interval);
91919191
this.interval = setInterval(() => framework.cache.recycle(), 1000 * 60);
9192-
framework.config['default-interval-cache-snapshot'] && this.load();
9192+
framework.config['allow-cache-snapshot'] && this.load();
91939193
return this;
91949194
};
91959195

@@ -9201,10 +9201,10 @@ FrameworkCache.prototype.save = function() {
92019201

92029202
FrameworkCache.prototype.load = function() {
92039203
var self = this;
9204-
Fs.readFile(framework.path.temp((framework.id ? 'i-' + framework.id + '_' : '') + 'framework.jsoncache'), function(err, response) {
9204+
Fs.readFile(framework.path.temp((framework.id ? 'i-' + framework.id + '_' : '') + 'framework.jsoncache'), function(err, data) {
92059205
if (err)
92069206
return;
9207-
var data = response.parseJSON();
9207+
data = data.toString('utf8').parseJSON();
92089208
if (data)
92099209
self.items = data;
92109210
});
@@ -9241,10 +9241,8 @@ FrameworkCache.prototype.recycle = function() {
92419241
}
92429242
}
92439243

9244-
var snapshot = framework.config['default-interval-cache-snapshot'];
9245-
snapshot && snapshot % self.count === 0 && self.save();
9244+
framework.config['allow-cache-snapshot'] && self.save();
92469245
framework._service(self.count);
9247-
92489246
return self;
92499247
};
92509248

0 commit comments

Comments
 (0)