Windshaft-cartodb/lib/cartodb/cache_validator.js

26 lines
687 B
JavaScript
Raw Normal View History

2015-03-16 07:16:36 +08:00
var Varnish = require('node-varnish');
var varnish_queue = null;
function init(host, port, secret) {
varnish_queue = new Varnish.VarnishQueue(host, port, secret);
varnish_queue.on('error', function(e) {
console.log("[CACHE VALIDATOR ERROR] " + e);
});
2011-12-01 02:59:28 +08:00
}
function invalidate_db(dbname, table) {
var cmd = 'purge obj.http.X-Cache-Channel ~ "^' + dbname +
':(.*'+ table +'.*)|(table)$"';
try{
varnish_queue.run_cmd(cmd, false);
} catch (e) {
console.log("[CACHE VALIDATOR ERROR] could not queue command " +
cmd + " -- " + e);
}
}
2011-12-01 02:59:28 +08:00
module.exports = {
init: init,
invalidate_db: invalidate_db
2015-03-16 06:46:59 +08:00
};