What is Store?
Store is a library for “Async Data Loading and Caching” developed by the New York Times Android team. I’ve converted an app to use it, and here are a few thoughts.
The Store documentation is good, and I don’t want to duplicate it here. At it’s simplest, it’s just a fetcher and an in-memory cache. You supply the fetcher, and typically it would be a Retrofit call, although it could also be some computationally expensive calculation.
The in-memory cache only persists as long as the app is running, so a persistent filesystem cache is also provided. This requires making some changes to your fetcher: moving any de-serialization to a separate parser, and returning a BufferedSource. Why? Caching already de-serialized objects would require serializing them to save, and then de-serializing them again on read. So caching the raw network data avoids the extra serialize/de-serialize steps.
What I’d Like to See
Better documentation for when the network is down, and there’s no value in the cache. Currently it throws NoSuchElementException, and I didn’t see it documented anywhere.
One thing I didn’t see is uploads. Store is currently download only; this issue discusses create/update/delete, but “For at least the foreseeable future this is not something we will be adding”.