Remove per-table varnish invalidation

This commit is contained in:
Raul Ochoa 2015-03-23 14:27:41 +01:00
parent 0e3f72ce0b
commit 02bc7b9fbf
3 changed files with 0 additions and 47 deletions

View File

@ -1,25 +0,0 @@
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);
});
}
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);
}
}
module.exports = {
init: init,
invalidate_db: invalidate_db
};

View File

@ -22,7 +22,6 @@
"Sandro Santilli <strk@vizzuality.com>"
],
"dependencies": {
"node-varnish": "https://github.com/Vizzuality/node-varnish/tarball/0.3.0",
"underscore" : "~1.6.0",
"dot": "~1.0.2",
"windshaft": "https://github.com/CartoDB/Windshaft/tarball/master",

View File

@ -1,21 +0,0 @@
var assert = require('../support/assert');
require(__dirname + '/../support/test_helper');
var CacheValidator = require(__dirname + '/../../lib/cartodb/cache_validator');
var VarnishEmu = require('../support/VarnishEmu');
suite('cache_validator', function() {
test('should call purge on varnish when invalidate database', function(done) {
var varnish = new VarnishEmu(function(cmds) {
assert.ok(cmds.length == 1);
assert.equal('purge obj.http.X-Cache-Channel ~ \"^test_db:(.*test_cache.*)|(table)$\"\n', cmds[0].toString('utf8'));
done();
},
function() {
CacheValidator.init('localhost', 1337);
CacheValidator.invalidate_db('test_db', 'test_cache');
});
});
});