jmdobry / angular-cache

angular-cache is a very useful replacement for the Angular 1 $cacheFactory.
http://jmdobry.github.io/angular-cache
MIT License
1.39k stars 156 forks source link

Remove all caches #37

Closed dmitrybelyakov closed 11 years ago

dmitrybelyakov commented 11 years ago

Hi there!

It might be nice to have an option to clear all caches without calling each one by name. I think I can wrap cache factory to keep track of all the created caches but maybe there is such an option already?

jmdobry commented 11 years ago

$cacheFactory has limited functionality, and no ability to remove all caches at once.

With $angularCacheFactory you could do the following to clear all caches:

var keySet = $angularCacheFactory.keySet();
for (var key in keySet) {
  $angularCacheFactory.get(key).removeAll();
}

or

var keySet = $angularCacheFactory.keySet();
for (var key in keySet) {
  $angularCacheFactory.get(key).destroy();
}
dmitrybelyakov commented 11 years ago

Yes, I was reffering to angularCacheFactory. Thanks for the tip and an awesome lib!

jmdobry commented 11 years ago

No problem!

Do you think it is worth it to add removeAll() and clearAll() to the $angularCacheFactory object?

blaster151 commented 11 years ago

Yes, please (in my opinion)! :)

On Tuesday, September 3, 2013, Jason Dobry wrote:

No problem!

Do you think it is worth it to add removeAll() and clearAll() to the $angularCacheFactory object?

— Reply to this email directly or view it on GitHubhttps://github.com/jmdobry/angular-cache/issues/37#issuecomment-23724905 .

jmdobry commented 11 years ago

K. They should make it into v1.1.0.

dmitrybelyakov commented 11 years ago

Yes and thank you. That would be quite convenient :)