Windshaft-cartodb/lib/cartodb/cache_validator.js
Sandro Santilli dfc4a02398 Fix X-Cache-Channel for multilayer (by token) responses
Required upgrading Windshaft to 0.9.2
Includes testcases
2013-03-13 16:45:15 +01:00

22 lines
682 B
JavaScript

var _ = require('underscore'),
Varnish = require('node-varnish'),
varnish_queue = null;
function init(host, port) {
varnish_queue = new Varnish.VarnishQueue(host, port);
}
function invalidate_db(dbname, table) {
try{
varnish_queue.run_cmd('purge obj.http.X-Cache-Channel ~ "^' + dbname + ':(.*'+ table +'.*)|(table)$"');
console.log('[SUCCESS FLUSHING CACHE]');
} catch (e) {
console.log("[ERROR FLUSHING CACHE] Is enable_cache set to true? Failed for: " + 'purge obj.http.X-Cache-Channel ~ "^' + dbname + ':(.*'+ table +'.*)|(table)$"');
}
}
module.exports = {
init: init,
invalidate_db: invalidate_db
}