Remove table param from generateCacheChannel

This commit is contained in:
Raul Ochoa 2015-03-23 18:58:57 +01:00
parent d5e20ef558
commit 1d433bf5b2

View File

@ -121,6 +121,11 @@ module.exports = function(redisPool) {
var dbName = req.params.dbname;
var cacheKey = [ dbName, req.params.token ].join(':');
// no token means no tables associated
if (!req.params.token) {
return callback(null, this.buildCacheChannel(dbName, []));
}
step(
function checkCached() {
if ( me.channelCache.hasOwnProperty(cacheKey) ) {
@ -137,7 +142,6 @@ module.exports = function(redisPool) {
if ( ! app.mapStore ) {
throw new Error('missing channel cache for token ' + req.params.token);
}
var next = this;
var mapStore = app.mapStore;
step(
function loadFromStore() {
@ -149,22 +153,24 @@ module.exports = function(redisPool) {
}
assert.ifError(err);
return mapConfig.obj().layers.map(function(lyr) {
return lyr.options.sql;
}).join(';');
var queries = mapConfig.getLayers()
.map(function(lyr) {
return lyr.options.sql;
})
.filter(function(sql) {
return !!sql;
});
return queries.length ? queries.join(';') : null;
},
function finish(err, sql) {
next(err, sql);
}
this
);
},
function findAffectedTables(err, sql) {
assert.ifError(err);
if ( ! sql ) {
if ( ! req.params.table ) {
throw new Error("this request doesn't need an X-Cache-Channel generated");
}
return [req.params.table];
throw new Error("this request doesn't need an X-Cache-Channel generated");
}
queryTablesApi.getAffectedTablesInQuery(cdbRequest.userByReq(req), sql, this); // in addCacheChannel
@ -172,16 +178,13 @@ module.exports = function(redisPool) {
function buildCacheChannel(err, tableNames) {
assert.ifError(err);
if (req.profiler && ! req.params.table ) {
if (req.profiler) {
req.profiler.done('affectedTables');
}
var cacheChannel = me.buildCacheChannel(dbName,tableNames);
// store for caching from me.generateCacheChannel
// (not worth when table was specified in params)
if ( ! req.params.table ) {
me.channelCache[cacheKey] = cacheChannel;
}
me.channelCache[cacheKey] = cacheChannel;
return cacheChannel;
},
function finish(err, cacheChannel) {