Use ES6 class syntax
This commit is contained in:
parent
b55c2ec55c
commit
329b5d9b9e
12
lib/cartodb/cache/named_map_provider_cache.js
vendored
12
lib/cartodb/cache/named_map_provider_cache.js
vendored
@ -8,7 +8,8 @@ const { templateName } = require('../backends/template_maps');
|
||||
const TEN_MINUTES_IN_MILLISECONDS = 1000 * 60 * 10;
|
||||
const ACTIONS = ['update', 'delete'];
|
||||
|
||||
function NamedMapProviderCache(
|
||||
module.exports = class NamedMapProviderCache {
|
||||
constructor (
|
||||
templateMaps,
|
||||
pgConnection,
|
||||
metadataBackend,
|
||||
@ -28,9 +29,7 @@ function NamedMapProviderCache(
|
||||
ACTIONS.forEach(action => templateMaps.on(action, (...args) => this.invalidate(...args)));
|
||||
}
|
||||
|
||||
module.exports = NamedMapProviderCache;
|
||||
|
||||
NamedMapProviderCache.prototype.get = function(user, templateId, config, authToken, params, callback) {
|
||||
get (user, templateId, config, authToken, params, callback) {
|
||||
const namedMapKey = createNamedMapKey(user, templateId);
|
||||
const namedMapProviders = this.providerCache.get(namedMapKey) || {};
|
||||
const providerKey = createProviderKey(config, authToken, params);
|
||||
@ -56,10 +55,11 @@ NamedMapProviderCache.prototype.get = function(user, templateId, config, authTok
|
||||
this.providerCache.set(namedMapKey, namedMapProviders);
|
||||
|
||||
return callback(null, namedMapProviders[providerKey]);
|
||||
};
|
||||
}
|
||||
|
||||
NamedMapProviderCache.prototype.invalidate = function(user, templateId) {
|
||||
invalidate (user, templateId) {
|
||||
this.providerCache.del(createNamedMapKey(user, templateId));
|
||||
}
|
||||
};
|
||||
|
||||
function createNamedMapKey (user, templateId) {
|
||||
|
Loading…
Reference in New Issue
Block a user