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

19 lines
506 B
JavaScript
Raw Normal View History

'use strict';
2015-04-27 22:18:50 +08:00
var FastlyPurge = require('fastly-purge');
2019-10-22 01:07:24 +08:00
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
*/
2019-10-22 01:07:24 +08:00
FastlyCacheBackend.prototype.invalidate = function (cacheObject, callback) {
2015-04-27 22:18:50 +08:00
this.fastlyPurge.key(this.serviceId, cacheObject.key(), callback);
};