angular-cache doesn't clear local storage cache when using DSCacheFactory.destroyAll or clearAll

202 Views Asked by At

I'm using angular-cache for the localStorage functionality. However, I have found that when trying to destroy or empty all of my caches, only the in memory cache seems to be cleared, not the localStorage cache. How can I make it so both caches are cleared?

1

There are 1 best solutions below

0
William Neely On

I submitted a bug report. In the meantime, I've implemented this code immediately after a call to DSCacheFactory.destroyAll():

for(var i in $window.localStorage){
    if(i.indexOf("angular-cache.caches")>-1){
      $window.localStorage.removeItem(i);
    }
}