Redis_GetInt gets wrong value when a key/value has not been set or the key was deleted
Closed this issue · 4 comments
new valIntRedis;
Redis_GetInt(servidor[redisControl], "test1", valIntRedis); // Redis_GetInt without set KEY VALUE
printf("%d",valIntRedis); // prints wrong value (1703440), expected to print "zero"
new valIntRedis2;
Redis_SetInt(servidor[redisControl], "test1", 12345);
Redis_GetInt(servidor[redisControl], "test1", valIntRedis2);
printf("%d",valIntRedis2); // prints correct value (12345)
Redis_Command(servidor[redisControl], "DEL test1"); // Delete key "test1"
new valIntRedis3;
Redis_GetInt(servidor[redisControl], "test1", valIntRedis3); // Redis_GetInt with deleted KEY
printf("%d",valIntRedis3); // prints wrong value (49000184), expected to print "zero"
I have used version 1.1.2 of the plugin (latest version)
Thanks for reporting, I will take a look at this problem.
@AlejandroMHA I believe this is normal behaviour, since the return from the native is 1 and not 0, meaning the key did not exist.
so you should be checking the return type of Redis_GetInt
and if the return type is not 0, then the key does not exist
@AlejandroMHA I believe this is normal behaviour, since the return from the native is 1 and not 0, meaning the key did not exist.
so you should be checking the return type of
Redis_GetInt
and if the return type is not 0, then the key does not exist
Thanks for the info, I just validated the native "Redis_GetInt" and it returns "3" when no key exists and "0" when a key exists.
I will consider in my script when the return value is different than 0 it will be interpreted as a key that does not exist.
Generally, a return value of zero indicates success in most software.