2018-10-23 23:45:42 +08:00
|
|
|
'use strict';
|
|
|
|
|
2015-07-15 22:51:26 +08:00
|
|
|
var LruCache = require('lru-cache');
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
function LayergroupAffectedTables () {
|
2015-07-15 22:51:26 +08:00
|
|
|
// dbname + layergroupId -> affected tables cache
|
|
|
|
this.cache = new LruCache({ max: 2000 });
|
2015-07-14 19:40:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = LayergroupAffectedTables;
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
LayergroupAffectedTables.prototype.hasAffectedTables = function (dbName, layergroupId) {
|
2015-07-15 22:51:26 +08:00
|
|
|
return this.cache.has(createKey(dbName, layergroupId));
|
2015-07-14 19:40:41 +08:00
|
|
|
};
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
LayergroupAffectedTables.prototype.set = function (dbName, layergroupId, affectedTables) {
|
2015-07-15 22:51:26 +08:00
|
|
|
this.cache.set(createKey(dbName, layergroupId), affectedTables);
|
2015-07-14 19:40:41 +08:00
|
|
|
};
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
LayergroupAffectedTables.prototype.get = function (dbName, layergroupId) {
|
2015-07-15 22:51:26 +08:00
|
|
|
return this.cache.get(createKey(dbName, layergroupId));
|
2015-07-14 19:40:41 +08:00
|
|
|
};
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
function createKey (dbName, layergroupId) {
|
2015-07-14 19:40:41 +08:00
|
|
|
return dbName + ':' + layergroupId;
|
|
|
|
}
|