fastify / fastify-caching

A Fastify plugin to facilitate working with cache headers
MIT License
201 stars 26 forks source link

Fixed 'ERR value is not an integer or out of range' issue #143

Closed akama-aka closed 7 months ago

akama-aka commented 7 months ago

As described in this issue https://github.com/redis/node-redis/issues/1505 in the comments, the ttl must be a string and must not be an integer. If you would use an integer you would get the following error: ReplyError: ERR value is not an integer or out of range or it would set nothing into the Redis Database.

Checklist

akama-aka commented 7 months ago

Because of the reason I cant commit test files its also not in the pr included. But I can give a Screenshot grafik And the npm run benchmark Script is also non existent.

gurgunday commented 7 months ago

Why did the tests not fail if this is wrong?

I found the error that in my code I was calculating expiry time like this 6060 but I passed the same in string "6060" so that was the issue writing 3600 in integer solved my problem.

People say integer works? Make sure it's not a float however

akama-aka commented 7 months ago

Why did the tests not fail if this is wrong?

I found the error that in my code I was calculating expiry time like this 60_60 but I passed the same in string "60_60" so that was the issue writing 3600 in integer solved my problem.

People say integer works? Make sure it's not a float however

I set my ttl to 1000 and still got everytime the issue. Idk why the tests not failed

akama-aka commented 7 months ago

I tested it now with 3600 and yes theres no error but it doesnt add it to the redis DB

akama-aka commented 7 months ago

We have a test that explicitly shows integers are supported:

https://github.com/fastify/fastify-caching/blob/01266faae80c7e7dbae5976d5cf3ae671c974cb0/test/cache.test.js#L34-L39

Please provide a reproduction in the form of a failing test.

I cant upload tests

We have a test that explicitly shows integers are supported:

https://github.com/fastify/fastify-caching/blob/01266faae80c7e7dbae5976d5cf3ae671c974cb0/test/cache.test.js#L34-L39

Please provide a reproduction in the form of a failing test.

Yea just with the difference that it doesnt use Redis as far I saw. ;-;