I just started using angular-cache and saw this question on stack overflow, where the user asked if the ngResource transformResponse function is called before cache. Apparently, the answer is no.
However, is it possible that there is no way around this? In my API, I return an object with so many information (other objects, arrays etc, which I don't need). All I need to cache are simply their id's.
How is this possible? This is what I had in mind:
app.factory('Operator', function($resource, API_CONFIG_URL, CacheFactory) {
var opsCache = CacheFactory.get('manageableOperatorsCache');
return $resource(API_CONFIG_URL+ '/operators/:id', {id: '@id'}, {
'get': {
method:'GET',
transformResponse: function(data, headers) {
// transform object to this format: ids : [1, 2, 3]
},
cache: opsCache
},
});
});
Thanks for your help :)
As a workaround for this I populate the cache myself by using
CacheFactory.put(key, value)intransformResponsefunction