Windshaft-cartodb/lib/cache/layergroup-affected-tables.js

27 lines
781 B
JavaScript
Raw Normal View History

'use strict';
var LruCache = require('lru-cache');
2019-10-22 01:07:24 +08:00
function LayergroupAffectedTables () {
// dbname + layergroupId -> affected tables cache
this.cache = new LruCache({ max: 2000 });
}
module.exports = LayergroupAffectedTables;
2019-10-22 01:07:24 +08:00
LayergroupAffectedTables.prototype.hasAffectedTables = function (dbName, layergroupId) {
return this.cache.has(createKey(dbName, layergroupId));
};
2019-10-22 01:07:24 +08:00
LayergroupAffectedTables.prototype.set = function (dbName, layergroupId, affectedTables) {
this.cache.set(createKey(dbName, layergroupId), affectedTables);
};
2019-10-22 01:07:24 +08:00
LayergroupAffectedTables.prototype.get = function (dbName, layergroupId) {
return this.cache.get(createKey(dbName, layergroupId));
};
2019-10-22 01:07:24 +08:00
function createKey (dbName, layergroupId) {
return dbName + ':' + layergroupId;
}