Windshaft-cartodb/lib/cache/backend/fastly.js

19 lines
504 B
JavaScript
Raw Normal View History

'use strict';
2015-04-27 22:18:50 +08:00
var FastlyPurge = require('fastly-purge');
function FastlyCacheBackend(apiKey, serviceId) {
2015-04-27 22:18:50 +08:00
this.serviceId = serviceId;
this.fastlyPurge = new FastlyPurge(apiKey, { softPurge: false });
2015-04-27 22:18:50 +08:00
}
module.exports = FastlyCacheBackend;
/**
* @param cacheObject should respond to `key() -> String` method
* @param {Function} callback
*/
FastlyCacheBackend.prototype.invalidate = function(cacheObject, callback) {
this.fastlyPurge.key(this.serviceId, cacheObject.key(), callback);
};