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

Why does angular-cache ignore capacity configuration? #210

Closed
valnub opened this issue Dec 30, 2015 · 0 comments
Closed

Why does angular-cache ignore capacity configuration? #210

valnub opened this issue Dec 30, 2015 · 0 comments

Comments

@valnub
Copy link

valnub commented Dec 30, 2015

I use angular-cache with localStorage to save articles locally in html5. The documentation states that there is an option called "capacity":

capacity

Maximum number of items a cache can hold. Adding more items
than the capacity will cause the cache to operate like an LRU cache,
removing the least recently used items to stay under capacity.
Default: Number.MAX_VALUE.

Since I only want to store a max of 20 articles, I configure like this:

CacheFactory('articleCache', {
  storagePrefix : 'my.news.',
  capacity : 20,
  storageMode: 'localStorage'
});

And when I want to get data, I simply do:

$http.get(url, {cache: CacheFactory.get('articleCache')});

After using my app for a while I suddenly noticed that it stopped working because localStorage limit quota was reached. When I printed console.log(localStorage), I saw that there were a lot more than just 20 articles stored to localStorage. So, for some reason angular-cache does not delete the oldest items although the documentation promised the opposite.

So, did I do something wrong or is there a bug in angular-cache?

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

No branches or pull requests

2 participants