11

Is there a way to get all of the keys out of a cache in Angular, specifically the template cache?

I don't see anything about how to do this in the documentation for the $cacheFactory or for the $templateCache. (Or from Google or SO....)

Jesus is Lord
  • 14,971
  • 11
  • 66
  • 97

3 Answers3

4

I'm not that into the angular build in $cacheFactory, because we use the $angularCacheFactory from https://github.com/jmdobry/angular-cache. There you can actually do such things via keys() or keySet()

xam.esurk
  • 133
  • 4
0

Since the cacheFactory implements a self-contained LRU cache, you don't need to peek at the keys since you can always to use .get() to try to get the value. You will either hit or miss the cache.

I created a peek() function and submitted a patch.

zs2020
  • 53,766
  • 29
  • 154
  • 219
  • I just tried that and I don't think it worked. Info only gives the name and the size - no keys. http://jsfiddle.net/NfLfT/1/ – Jesus is Lord Aug 26 '13 at 15:47
0

Template keys are 'templates-app' dependancies, so you can access them as

var keys = angular.module('templates-app').requires; //array of keys
krio
  • 101
  • 1