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

Override default $resource cache #246

Open
artemgrygor opened this issue Oct 13, 2016 · 4 comments
Open

Override default $resource cache #246

artemgrygor opened this issue Oct 13, 2016 · 4 comments

Comments

@artemgrygor
Copy link

artemgrygor commented Oct 13, 2016

Hi all,

I'm trying to use angular-cache as default one for $recourse.
At app.run

$http.defaults.cache = CacheFactory('defaultCache', {
  maxAge: 15 * 60 * 1000, // Items added to this cache expire after 15 minutes
  cacheFlushInterval: 60 * 60 * 1000, // This cache will clear itself every hour
  deleteOnExpire: 'aggressive' // Items will be deleted from this cache when they expire
});

Api.js config file (it is registered before app.run):

msApiProvider.register('currency', [
  '/api/currencies',
  {},
  {
    query: {
      method: 'GET',
      params: {},
      isArray: true,
      cache: true
    }
  }
]);

However, when I try to get this keys array is empty

var cache = CacheFactory.get('defaultCache');
var keys = cache.keys();

Any ideas?
Thanks

@yogeshgadge
Copy link

Do you have a plnkr to reproduce ? Or can you show your $resource call/query to do that get ? Also what is msApiProvider.

@Droppers
Copy link

This does not work.

@jmdobry
Copy link
Owner

jmdobry commented Dec 12, 2016

A plunker to reproduce would be most helpful to debug this!

@viniciusaugutis
Copy link

You may be trying to use the cache without having been instantiated yet.
Or try putting "cache: CacheFactory.get ('defaultCache')" instead of "cache: true"

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

5 participants