dfc4a02398
Required upgrading Windshaft to 0.9.2 Includes testcases
22 lines
682 B
JavaScript
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
|
|
}
|