-
Notifications
You must be signed in to change notification settings - Fork 152
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
Discussion: why have an client side API cache? #373
Comments
The cache is used to avoid listing resources each time we need to get a resourced based on something else than its ID, for example querying a server based on its hostname $ scw _flush-cache >/dev/null
$ time scw --debug inspect --format '{{ .Hostname }}' server:swarm-node-1
DEBU[0000] Filling the cache
DEBU[0000] curl -X GET -H "Content-Type: application/json" -H "User-Agent: scw/v1.9.0+dev" -H "X-Auth-Token: 00000000-0000-1000-0000-000000000000" https://api.scaleway.com/servers
DEBU[0001] curl -X GET -H "Content-Type: application/json" -H "User-Agent: scw/v1.9.0+dev" -H "X-Auth-Token: 00000000-0000-1000-0000-000000000000" https://api.scaleway.com/servers/22baa68d-e439-48d1-9437-b1a764f34acc
swarm-node-1
0.11s user 0.03s system 8% cpu 1.821 total
$ time scw --debug inspect --format '{{ .Hostname }}' server:swarm-node-1
DEBU[0000] curl -X GET -H "Content-Type: application/json" -H "User-Agent: scw/v1.9.0+dev" -H "X-Auth-Token: 00000000-0000-1000-0000-000000000000" https://api.scaleway.com/servers/22baa68d-e439-48d1-9437-b1a764f34acc
swarm-node-1
0.12s user 0.02s system 29% cpu 0.460 total
When you create a server with a named It is also used by the autocomplete scripts of the CLI that will only look in this cache file to avoid querying the API just for autocomplete As you did in #369, I'm fully 👍 to keep this feature in the CLI, but make it optional when using the API sdk Looks good to you ? |
@moul thanks for explaining! I fully understand the use case for the CLI. I'll check if there's a nice way to migrate the caching for cli only. |
I'm wondering why the API SDK has a local cache? Assuming you're already caching on the server side the client cache probably doesn't add a lot of benefit but some maintenance burden.
Removing the cache would simplify the API SDK a little, and also remove one possible point for errors (less caches = less stale results)
The text was updated successfully, but these errors were encountered: