jmdobry/angular-cache

using as direct replacement in $resource for $cacheFactory doesnt work

Closed this issue · 9 comments

I tried using angular-cache, but couldnt get it to store. Tries many things and then tried to just use %cacheFactory instead in a resource. It worked as expected. Size increased.

 cache = $cacheFactory.get('tagCloudCache2') || $cacheFactory('tagCloudCache2');    ** works **

 cache = DSCacheFactory.get('tagCloudCache') ||  DSCacheFactory('tagCloudCache', {
                    maxAge:  5 * 60 * 1000, // 5 mins
                    deleteOnExpire: 'aggressive'
                });  ** doesnt work **

calling with:

return customResource('x/:xId/tags/_cloud', {xId: sId}, cache).query().$promise.then

using custom resource:

.factory('customResource', ['$resource','baseUrls','$rootScope',
        function($resource, baseUrls, $rootScope){
            return function (url, params, cache){

                function formatResponse(data, headersGetter) {
                  ....
                }

                return $resource(
                    baseUrls.api+'/'+url+'/',
                    params,
                    {
                        get:    {method:'GET', transformResponse:formatResponse, cache:cache},
                        query:  {method:'GET', transformResponse:formatResponse, cache:cache},
                        update: {method:'PUT'}
                    }
                );
            };
}])

Try with angular-cache 2.x. Angular-cache 4.x should work better with ngResource.

Thanks. Is there an issue with 3.0? I thought it was meant for drop in replacement.

Cheers
Shane

On 16 Mar 2015, at 02:18, Jason Dobry notifications@github.com wrote:

Try with angular-cache 2.x. Angular-cache 4.x should work better with ngResource.


Reply to this email directly or view it on GitHub.

There is one specific assumption that only ngResource makes about the implementation of a cache, which (I think) prevents angular-cache 3.x from being used with ngResource. This is discussed in two other issues. 3.x works fine if you're not using ngResource. 4.x will work with ngResource.

cool, thanks for speedy reply.
Any issues with using 2.x until 4.x?
Shane

Date: Mon, 16 Mar 2015 08:13:16 -0700
From: notifications@github.com
To: angular-cache@noreply.github.com
CC: swilli40@hotmail.com
Subject: Re: [angular-cache] using as direct replacement in $resource for $cacheFactory doesnt work (#161)

There is one specific assumption that only ngResource makes about the implementation of a cache, which (I think) prevents angular-cache 3.x from being used with ngResource. This is discussed in two other issues. 3.x works fine if you're not using ngResource. 4.x will work with ngResource.


Reply to this email directly or view it on GitHub.

No, though 2.x has some deprecated parts that won't be in 4.x

tried with 2.4.1, get the same….

thanks

Shane

On 16 Mar 2015, at 15:15, Jason Dobry notifications@github.com wrote:

No, though 2.x has some deprecated parts that won't be in 4.x


Reply to this email directly or view it on GitHub #161 (comment).

Can you create a plunker of jsfiddle that demonstrates the issue?

Should be fixed in 4.0.0

ngResource is now officially support in 4.1.0