-
Notifications
You must be signed in to change notification settings - Fork 2k
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
apollo-server-redis SET method called with ttl 0 #1306
Comments
Hi @raduachim! If you are using the Datasources API on top of a REST API that already has standard cache-control headers set, these will be passed through directly to I suspect there are some rounding issues with converting milliseconds to seconds while parsing the cache-control header, will look into that! |
Thanks for the response @clarencenpy So just to make sure I understand this correctly - this works only if the REST API has the cache-control headers set? When the headers are not set I can see that the redis |
Hi I think I understand now how it should work. I've looked a bit in the code and what I can tell is that the A |
Hi @raduachim, thanks for digging in on this! It seems like the easiest fix would be to |
@clarencenpy Thanks. I realized it should be a Math.round rather than a parseInt. |
PR merged, closing issue. Thanks @raduachim for working on this! |
Hi,
I am trying to understand how to use
apollo-server-redis
for caching calls to a REST api.For me it's a bit confusing from the docs how the flow would work.
For the graphql server I am using:
I have a simple Redis inside a container and have configured my apollo server with:
On my type in the schema I have added a
@cacheControl(maxAge: 600)
and then I tried my query only to receive the error:"message": "ERR invalid expire time in set",
Digging a bit in the
apollo-server-redis
code I see that theset
method is called withoptions
that has a keyttl
with value 0.After some more experimenting I see that I need to set in my REST api in the response header the header
cache-control: max-age=1337
. Might be a stupid question, but why do I need to do this?And after configured my REST api to return this cache-control header, the
set
method in theapollo-server-redis
is being called with a float value, not 1337 but rather 1336.24 or something similar.Which also breaks when trying to set something in Redis. So it seems to need some
parseInt
The text was updated successfully, but these errors were encountered: