Shared cache for affected tables in layergroup and map controllers

This commit is contained in:
Raul Ochoa
2015-07-14 13:40:41 +02:00
parent c295584864
commit e8b5845174
8 changed files with 120 additions and 63 deletions
+22
View File
@@ -0,0 +1,22 @@
function LayergroupAffectedTables() {
// layergroupId -> affected tables cache
this.cache = {};
}
module.exports = LayergroupAffectedTables;
LayergroupAffectedTables.prototype.hasAffectedTables = function(dbName, layergroupId) {
return this.cache.hasOwnProperty(createKey(dbName, layergroupId));
};
LayergroupAffectedTables.prototype.set = function(dbName, layergroupId, affectedTables) {
this.cache[createKey(dbName, layergroupId)] = affectedTables;
};
LayergroupAffectedTables.prototype.get = function(dbName, layergroupId) {
return this.cache[createKey(dbName, layergroupId)];
};
function createKey(dbName, layergroupId) {
return dbName + ':' + layergroupId;
}
+4
View File
@@ -15,6 +15,10 @@ DatabaseTables.prototype.key = function() {
}.bind(this));
};
DatabaseTables.prototype.getCacheChannel = function() {
return this.dbName + ':' + this.tableNames.join(',');
};
function shortHashKey(target) {
return crypto.createHash('sha256').update(target).digest('base64').substring(0,6);
}