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

Possible regression in 2.3.1 #100

Closed cwerner87 closed 10 years ago

cwerner87 commented 10 years ago

When I upgraded angular-cache from 2.3.0 to 2.3.1, I noticed after my cache in localStorage would expire that I would get errors when angular-cache attempted to parse the cache. I reverted to 2.3.0 and the problem vanished. Here's a plunker that shows the issue (I can repro on Firefox/Chrome):

http://plnkr.co/edit/PoXRGBvetOh1zYyhAV6e

What seems to be happening is after the cache expires, it writes "undefined" to the local storage and it attempts to call JSON.parse on the undefined string, causing a syntax error.

Is this a regression or did something change in the API and I need to change my implementation?