tursodatabase / turso-cli

Command line interface to Turso.

Home Page:https://turso.tech

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CLI data cache gets out of date with changes from other sources, need mechanism to force a cache reset

CodingDoug opened this issue · comments

The CLI caches various bits of data from the underlying platform API. When there are changes from other sources, the cache doesn't reset until expiration. This can be confusing for users of the CLI who aren't aware that it does caching at all. Recovering from this before expiration requires manually manipulating settings.json, which is not great. We could provide a way for people to either bypass the cache on a per-command basis, or reset it entirely with a command.

For example: turso db list --force
Or: turso cache reset

commented

turso db list should bypass the cache and populate it with fresh results.

The cache should be mainly used by:

  • Commands which need information from a specific database, such as turso db shell.
  • Autocomplete.

For instance, turso db shell foo it should try to find the database foo from the cache.
In case it isn't there, it shouldn't trust the cache and hit the API.

@avinassh FYI.

I reopened this issue. Though the bug is fixed, we should explore the options mentioned in the OP, that a way to reset the cache should exist

a way to reset the cache should exist

Do you mean the entire cache, and only the cache, in settings.json (preserving everything else)? Or do you mean only the cache relevant on a per-command basis? The examples I showed are different in that respect.
@avinassh

I would prefer per command basis, something like db list --no-cache

commented

I disagree. The cache shouldn't be used at the expense of user experience.
If the user has to be aware that we using caches, we're probably using it wrong.

Ideally:

  • CLI commands should display data from the source of truth (e.g. turso db list).
    • It is OK for a command like this to take around a second or even more.
  • Where latency can be improved, and exposing stale data is not a problem, we can rely on caches.
    • Completions for database names and locations are a good example. Also because it is not OK to wait for a second when you're hitting tab to wait for an autocomplete.

If that makes sense to you, please close the issue.

@athoscouto Having a command to wipe the entire current cache would still be helpful as a way for someone to get out of a bad situation without having to manually locate and edit configs. We shouldn't necessary assume all of our code that deals with cache is bug-free, or directly addresses the interests of the developer.