diff --git a/lib/cartodb/cache/named_map_provider_cache.js b/lib/cartodb/cache/named_map_provider_cache.js index e5f63d63..c65a4bca 100644 --- a/lib/cartodb/cache/named_map_provider_cache.js +++ b/lib/cartodb/cache/named_map_provider_cache.js @@ -32,31 +32,29 @@ module.exports = NamedMapProviderCache; NamedMapProviderCache.prototype.get = function(user, templateId, config, authToken, params, callback) { var namedMapKey = createNamedMapKey(user, templateId); var namedMapProviders = this.providerCache.get(namedMapKey) || {}; - var providerKey = createProviderKey(config, authToken, params); - if (!namedMapProviders.hasOwnProperty(providerKey)) { - namedMapProviders[providerKey] = new NamedMapMapConfigProvider( - this.templateMaps, - this.pgConnection, - this.metadataBackend, - this.userLimitsBackend, - this.mapConfigAdapter, - this.affectedTablesCache, - user, - templateId, - config, - authToken, - params - ); - this.providerCache.set(namedMapKey, namedMapProviders); - // early exit, if provider did not exist we just return it + if (namedMapProviders.hasOwnProperty(providerKey)) { return callback(null, namedMapProviders[providerKey]); } - var namedMapProvider = namedMapProviders[providerKey]; + namedMapProviders[providerKey] = new NamedMapMapConfigProvider( + this.templateMaps, + this.pgConnection, + this.metadataBackend, + this.userLimitsBackend, + this.mapConfigAdapter, + this.affectedTablesCache, + user, + templateId, + config, + authToken, + params + ); - return callback(null, namedMapProvider); + this.providerCache.set(namedMapKey, namedMapProviders); + + return callback(null, namedMapProviders[providerKey]); }; NamedMapProviderCache.prototype.invalidate = function(user, templateId) {