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

TypeError when cleaning or renewing cache #217

Closed pietro909 closed 8 years ago

pietro909 commented 8 years ago

Hello, I'm trying to force the request invalidating the cache this way:

var id = "myCache";
var cfg = { storageMode: "localStorage" };
var cache = cacheFactory.createCache(id, cfg);
// perform HTTP requests and get the result, cache is working well...
// ...now need to refresh data from server
cacheFactory.destroy(id);
cache = cacheFactory.createCache(id, cfg);
// perform again HTTP requests passing the new cache: 
// they are working as well but then I get...

TypeError: Cannot use 'in' operator to search for 'myApiUrl' in null at Object.e.(anonymous function).get [...]

Actually is failing at index.js:274 because $$data is null

if (!(key in $$data)) {
    return;
}

What am I doing wrong? I get the same error even using:

cache.removeAll();
// error in next request

Thank you!

pietro909 commented 8 years ago

Update: I built up a very small example and is working fine (angular-cache 4.2.2). In my application cache management and requests are handled in different modules, so is a problem on my side.