Move invalidation closer to its definition
This commit is contained in:
parent
3d2f554be9
commit
1bb6a2ac0d
@ -161,10 +161,6 @@ module.exports = class ApiRouter {
|
|||||||
layergroupAffectedTablesCache
|
layergroupAffectedTablesCache
|
||||||
);
|
);
|
||||||
|
|
||||||
['update', 'delete'].forEach(function(eventType) {
|
|
||||||
templateMaps.on(eventType, namedMapProviderCache.invalidate.bind(namedMapProviderCache));
|
|
||||||
});
|
|
||||||
|
|
||||||
const collaborators = {
|
const collaborators = {
|
||||||
analysisStatusBackend,
|
analysisStatusBackend,
|
||||||
attributesBackend,
|
attributesBackend,
|
||||||
|
@ -8,6 +8,7 @@ var templateName = require('../backends/template_maps').templateName;
|
|||||||
var LruCache = require("lru-cache");
|
var LruCache = require("lru-cache");
|
||||||
|
|
||||||
const TEN_MINUTES_IN_MILLISECONDS = 1000 * 60 * 10;
|
const TEN_MINUTES_IN_MILLISECONDS = 1000 * 60 * 10;
|
||||||
|
const ACTIONS = ['update', 'delete'];
|
||||||
|
|
||||||
function NamedMapProviderCache(
|
function NamedMapProviderCache(
|
||||||
templateMaps,
|
templateMaps,
|
||||||
@ -25,6 +26,8 @@ function NamedMapProviderCache(
|
|||||||
this.affectedTablesCache = affectedTablesCache;
|
this.affectedTablesCache = affectedTablesCache;
|
||||||
|
|
||||||
this.providerCache = new LruCache({ max: 2000, maxAge: TEN_MINUTES_IN_MILLISECONDS });
|
this.providerCache = new LruCache({ max: 2000, maxAge: TEN_MINUTES_IN_MILLISECONDS });
|
||||||
|
|
||||||
|
ACTIONS.forEach(action => templateMaps.on(action, (...args) => this.invalidate(...args)));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = NamedMapProviderCache;
|
module.exports = NamedMapProviderCache;
|
||||||
|
Loading…
Reference in New Issue
Block a user