Managing stale data with ember local storage adapter

What ways do you clear stale data from local storage when using the Ember local storage adapter? This is pretty crucial for when you make changes to model schemas. My first thought is just redeploy the application with a different namespace. This could work, but I’m curious what other approaches people have used. Thanks!

I created a base model that other models inherit from that holds a version number and a function for “upgrading schema”. Anytime a version number is recovered different than what is in the app the schema update is run. That and I make use of default values which help to fill in the gaps.

That being said the local storage adapter project looks dead in the water in the wake of recent ember data changes so tread lightly.

1 Like

That’s a neat way of doing it.

Yea I’m noticing that the LSAdapter addon is dead, has a few bugs, and doesn’t work with newer versions of Ember Data. But I’m not sure what to do otherwise except:

  1. delegate to the server and use RESTAdapter which will require more backend work
  2. write my own browser storage adapter which I dont feel super confident in since I am still pretty new to Ember

Are there any other approaches or packages people are using for browser storage?

If you don’t need full blown ember data objects you can use ember-local-storage. ember-local-storage - npm. It works pretty damn well but it only supports primitive objects.

2 Likes

Cool thanks for that!