Add maxAge param to lru-cache to be able to refresh entries when staled

This commit is contained in:
Daniel García Aubert 2019-09-12 18:02:13 +02:00
parent 64b4efef17
commit 9d6726227a

View File

@ -8,6 +8,8 @@ var queue = require('queue-async');
var LruCache = require("lru-cache"); var LruCache = require("lru-cache");
const TEN_MINUTES_IN_MILLISECONDS = 1000 * 60 * 10;
function NamedMapProviderCache( function NamedMapProviderCache(
templateMaps, templateMaps,
pgConnection, pgConnection,
@ -23,7 +25,7 @@ function NamedMapProviderCache(
this.mapConfigAdapter = mapConfigAdapter; this.mapConfigAdapter = mapConfigAdapter;
this.affectedTablesCache = affectedTablesCache; this.affectedTablesCache = affectedTablesCache;
this.providerCache = new LruCache({ max: 2000 }); this.providerCache = new LruCache({ max: 2000, maxAge: TEN_MINUTES_IN_MILLISECONDS });
} }
module.exports = NamedMapProviderCache; module.exports = NamedMapProviderCache;