Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues found in caching, need help #264

Open
sundertinwar opened this issue Aug 8, 2017 · 1 comment
Open

Issues found in caching, need help #264

sundertinwar opened this issue Aug 8, 2017 · 1 comment

Comments

@sundertinwar
Copy link

Hi,
I was trying to use this module into my project but not sure it is working properly or not. Below is the code –

angular.module('TrackerApp').factory('TrackerFactory', function ($resource, CacheFactory) {
if (!CacheFactory.get('CenterCache')) {
            console.log('cache does not exists');
              CacheFactory.createCache('CenterCache', {
                maxAge: 5 * 60 * 1000,
                deleteOnExpire: 'aggressive'
              });
        }
        var centerCache = CacheFactory.get('CenterCache');
var CenterClass = $resource(_ServiceBaseURL + 'api/Center/:id',{},{
            query: {
                method: 'GET',
                cache: centerCache,
                isArray:true
            }
         });        
        CenterClass.GetMultipleAsObject = function () { return this.query(); };
return {            
            CenterClass: CenterClass
        };
    });

On loading of app, it does print message in console that “cache does not exists” and it does create cache in local storage
“angular-cache.caches.CenterCache.keys” = [http://localhost/Services/Tracker/api/Center]
Another key is created
“angular-cache.caches.CenterCache.data.http:// localhost/Services/Tracker/api/Center” = mystoredvalue
Issues –

  1. On page refresh (f5), I do see the console message printed again and in http calls, I can see “Center” information is getting download, it is not picked from cache.
  2. On navigating from one page to another, I don’t see the console message getting printed. But I do see the "Center” api getting called and data being downloaded.

Am I missing something?

@MatheusArleson
Copy link

there is an issue in how the cache is handled in case it is an array.
please take a look on my comment on #251

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants