As per the AngularJS documentation, $resource service now has support for
caching as well.
cache – {boolean|Cache} – If true, a default $http cache will be used to
cache the GET request, otherwise if a cache instance built with
$cacheFactory, this cache will be used for caching.
So I may write $resource as follows:
app.factory('myResourceWithCache', function($resource, $cacheFactory) {
var myCache = $cacheFactory('MyCache');
return $resource(apiBaseUrl + '/myservice/:id', {id: '@id'}, {
'get': { method:'GET', cache: myCache },
'query': { method:'GET', cache: myCache , isArray:true }
});});
What I want to know is that:
1. what will be the name of key in the cache? For $http cache, key is
the path of service/api, is it going to be the same if we use custom cache?
2. Is there a way to provide key name on our own for the custom cache
(myCache here)
I tried AngularJS documentation and other stackoverflow threads but did not
find any answer for this. Please help.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.