Redis version : 3.0.5
This ticket was initially created in the IORedis repository (npm package). After a short talk with the author, we both think it should be directly reported here. This is my initial ticket :
"ioredis": "^2.0.1"
Today I experienced a difficult bug to solve, I changed few config files in my project, some of them are defining the TTL value of my HASH, SET, LIST for Redis.
I messed up with one file, for this reason the TTL value of one of my collections was undefined, and I was not able to found this collection anymore in my Redis. I finally debugged it by running my project step by step, this is what I discovered :
var ttl_value = undefined; redisClient.expire(key, ttl_value)
The result is an instant deletion of the redisElement corresponding to 鈥榢ey', without any error, warning or whatever.
Apparently undefined is considered as 0, which is probably unwanted and dangerous for most of the users.
Best regards,
According to the answer of the IORedis author, this behavior is directly linked to Redis core :
Good catch! Actually ioredis sends undefined to the Redis server directly without converting it to a 0. However Redis considers empty values as zero: https://github.com/antirez/redis/blob/226f679651ca62394021738af0ce467a290c7b90/src/object.c#L639-L641.
You can find the initial ticket here : https://github.com/luin/ioredis/issues/338
Best regards,
Hello, thanks for investigating this issue. I can acknowledge that the empty string as expire time results into the deletion of the key. This is unexpected so I'm fixing it. Thanks.
The bug is fixed now. Thanks.
Appreciate that, nice work btw