-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Caching on heavily-used API calls #3149
Comments
hi, @jywarren yeah, sure!! I'll add it to our Project page, this sounds good! |
@milaaraujo maybe this could be related to or folded into #4561? |
Hey @jywarren, I do not know how to implement this... They do not have good documentation beyond example. Do we need a key and an etag, right? But in our case what could we use since
|
So, we could build whatever is unique into the key -- what are the parameters that can change, when typing in the autocompletion, for example? Since the user is just typing like get :profiles do
search_request = SearchRequest.fromRequest(params)
cache(key: "api:profiles:#{params[:query]}", etag: post.updated_at, expires_in: 1.day) do
results = Search.execute(:profiles, params)
if results.present?
...
end
...
end What do you think? I'm not sure it's actually If we have other parameters, we could bake them into the key as well, so that the cache saves each variation. Even though most will be the same if via the autocomplete queries. But just so that other parameters don't match the same cache key, and so actually get fulfilled. What do you think? |
I'm not sure what the Perhaps the request can be tailored with etag to bust the cache... seems like a timestamp. I'm not sure -- maybe we could skip that parameter? |
Also, i wonder if we couldn't just use normal Rails caching, which might mean you can't bust the cache using something like plots2/app/helpers/questions_helper.rb Line 14 in 1802e62
|
We can skip |
We had some outages this morning due to an old, unoptimized API endpoint being hit hard by the new
@
autocomplete...https://github.com/monterail/grape-rails-cache
Implementation looks pretty simple! @stefannibrasil @milaaraujo interested in this? As your new code gets relied on more, this seems like a good idea...
The text was updated successfully, but these errors were encountered: