Closed willyboy closed 9 years ago
Closing because I’m not sure this is an issue, if you are convinced that this is really a bug, please feel free to re-open the issue and add more information:
Otherwise support is done via the mailing list.
Version is 3.2.5 so I haven't upgraded yet because I haven't been able to review if there are any breaking changes.
My storage code is:
if(!DSCacheFactory.get(this.source)){
DSCacheFactory(this.source);
}
var cache = {cache:DSCacheFactory.get(this.source)};
}
var that = this;
$http.get(this.source,cache)
}
I've also noticed that on first page load, DSCacheFactory.get(this.source)
is empty even if it exists in localStorage but DSCacheFactory(this.source)
loads the cache from storage. I guess I would expect DSCacheFactory.get(this.source)
to check localStorage since in my config I have:
DSCacheFactoryProvider.setCacheDefaults({
storageMode:"localStorage",
maxAge: 604800000, //7 days
deleteOnExpire: "passive" //don't scan for expired items
});
plunker demonstrating that it works with 4.2.0: http://plnkr.co/edit/hamvsZ?p=preview
plunker demonstrating that it works with 3.2.5: http://plnkr.co/edit/NiOEes?p=preview
Open the Resources tab in chrome devtools and observe the storage in http://run.plnkr.co
Does anything look inherently wrong in the code I pasted? If not, it could be related to Ionic. Besides the difference of using/not using http, I don't see a difference in the code yet yours clearly works.
I updated this plunker to more closely match the code in your example, and it still works. Seems like it's either an issue with ionic or the environment in which your app is running.
You could try 4.x. Here are the breaking changes moving from 3.x to 4.x.
Awesome, thanks for the help! If I discover anything about an incompatibility between Ionic and angular-cache I'll post it here just as a reference.
Cool
Cache data in local storage is not cleared when clear/destroy all calls are made.