@autofleet/matmon 2.0.6 → 2.0.7
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/lib/cache.js +7 -0
- package/package.json +1 -1
package/lib/cache.js
CHANGED
|
@@ -49,6 +49,11 @@ const getMutexByCacheKey = (key) => {
|
|
|
49
49
|
}
|
|
50
50
|
return MUTEX_MAP[key];
|
|
51
51
|
};
|
|
52
|
+
const deleteMutexByCacheKey = (key) => {
|
|
53
|
+
if (MUTEX_MAP[key]) {
|
|
54
|
+
delete MUTEX_MAP[key];
|
|
55
|
+
}
|
|
56
|
+
};
|
|
52
57
|
exports.getNewLRU = (lifeTimeInSec, size) => new lru_cache_1.default(getOptions({
|
|
53
58
|
lifeTimeInSec,
|
|
54
59
|
size,
|
|
@@ -70,12 +75,14 @@ exports.getWithCacheSupport = ({ cacheKey, cacheGet, cacheSet, fetching, skipCac
|
|
|
70
75
|
else {
|
|
71
76
|
// logger.info('get value from cache');
|
|
72
77
|
}
|
|
78
|
+
deleteMutexByCacheKey(cacheKey);
|
|
73
79
|
}));
|
|
74
80
|
// retry without locking if failed
|
|
75
81
|
}
|
|
76
82
|
catch (e) {
|
|
77
83
|
valueToReturn = yield fetching();
|
|
78
84
|
yield cacheSet(valueToReturn);
|
|
85
|
+
deleteMutexByCacheKey(cacheKey);
|
|
79
86
|
}
|
|
80
87
|
return valueToReturn;
|
|
81
88
|
});
|