@autofleet/node-common 1.4.9 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/settings/index.js +6 -2
package/package.json
CHANGED
package/settings/index.js
CHANGED
|
@@ -45,6 +45,10 @@ class SettingsManager {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
calcRandomTtl() {
|
|
49
|
+
return this.ttl + (1 + Math.random());
|
|
50
|
+
}
|
|
51
|
+
|
|
48
52
|
async get(key, defaultValue, labels = [], { timeout = 1000 } = {}) {
|
|
49
53
|
if (typeof defaultValue === 'undefined') {
|
|
50
54
|
throw new Error('Can\'t get a key without defaultValue');
|
|
@@ -93,13 +97,13 @@ class SettingsManager {
|
|
|
93
97
|
this.settingsCache.del(cacheKey);
|
|
94
98
|
throw e;
|
|
95
99
|
}
|
|
96
|
-
this.settingsCache.set(cacheKey, returnValue, this.
|
|
100
|
+
this.settingsCache.set(cacheKey, returnValue, this.calcRandomTtl());
|
|
97
101
|
return returnValue;
|
|
98
102
|
}
|
|
99
103
|
|
|
100
104
|
setLocal(key, labels, value) {
|
|
101
105
|
const cacheKey = `${key}_${JSON.stringify(labels)}`;
|
|
102
|
-
this.settingsCache.set(cacheKey, value, this.
|
|
106
|
+
this.settingsCache.set(cacheKey, value, this.calcRandomTtl());
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
flush() {
|