Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force cache invalidation on API version change #252

Open
anthonycr opened this issue Sep 7, 2017 · 1 comment
Open

Force cache invalidation on API version change #252

anthonycr opened this issue Sep 7, 2017 · 1 comment
Labels

Comments

@anthonycr
Copy link
Contributor

Issue Summary

When the API version changes, the cache is not cleared. This creates a potential for serialization crashes due to changes in object representations.

Suggested Improvements

Since the API version is no longer exposed to the library consumer, we should invalidate the retrofit cache when we detect an API version change internally. This will require us to persist the current version of the API to disk. We should do this either using a flat file (since this is a java library) or force the consumer to provide an implementation of an interface that writes and retrieves key value pairs to disk.

interface KeyValueStorage {
    fun storeStringForKey(key: String, value: String?)

    fun retrieveStringForKey(key: String): String?
}

Then we will force cache invalidation any time we detect a change in the API Version.

@anthonycr anthonycr added the bug label Sep 7, 2017
@kvenn
Copy link
Contributor

kvenn commented Sep 7, 2017

I like this. Ideally we would use Gson versions (which would map to the API version) in addition to this. Then only invalidate the cache if we know there will be a breaking change. This would also help us a bit with any other persistence (like turnstile).

https://sites.google.com/site/gson/gson-user-guide#TOC-Versioning-Support
Name changes: https://futurestud.io/tutorials/gson-model-annotations-multiple-deserialization-names-with-serializedname
http://memorynotfound.com/gson-versioning-support/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants