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

Update of existing mosaicjson does not update or clear cache #176

Open
philvarner opened this issue Jun 7, 2021 · 2 comments
Open

Update of existing mosaicjson does not update or clear cache #176

philvarner opened this issue Jun 7, 2021 · 2 comments

Comments

@philvarner
Copy link

The backend method read/get methods are wrapped in a cachetools ttl cache. Updating an existing mosaic will write this new value to the backend, but it won't be available to read for up to 5 minutes (default).

This is a complex behavior to implement correctly, but the existing implementation is confusing to users, especially because there is no documentation that this is the behavior. I would expect and update and the read to return what I just updated, not the old version until it expires.

@kylebarron
Copy link
Member

Interesting. So we should be able to call cache.clear() from inside the update method? https://stackoverflow.com/a/59443455

@philvarner
Copy link
Author

philvarner commented Jun 7, 2021

Interesting. So we should be able to call cache.clear() from inside the update method? https://stackoverflow.com/a/59443455

Yes, but you can also clear just one entry with pop, which is probably what should be done for read -- though I'm not sure how this can be cleared for the cache used by get_assets. It might require a more complex structure like per-path (mosaicid) and the then per-quadkey, so you can clear all the entries for a single mosaic in one go. Though, the cache is pretty small, so just locking and iterating through it on the (relatively rare) update operation probably isn't too bad.

This doc https://cachetools.readthedocs.io/en/stable/ has an example for manual cache clearing if you search for To perform operations on the cache object, for example to clear the cache during runtime

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

No branches or pull requests

2 participants