We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
It seems TTL values are typed as integers - https://github.com/phpredis/phpredis/blob/35a7cc09/redis.stub.php#L3066
Since Redis v2.6 the Redis stores all TTL values with milliseconds resolution, so I expect:
$redis->setEx('key', 30.5, 'value');
PHP float type always accepts an int, even with strict types, so no BC break is implied.
Code like:
$redisClient->pSetEx($cacheKey, (int) ($this->getCacheDataTTLSeconds() * 1000), $value);
could be then written as:
$redisClient->pSetEx($cacheKey, $this->getCacheDataTTLSeconds() * 1000, $value);
or even
$redisClient->setEx($cacheKey, $this->getCacheDataTTLSeconds(), $value);
which is shorter and more readable.
The text was updated successfully, but these errors were encountered:
It's an interesting question, but I don't really know the right answer.
The issue with code like this: $redis->setEx('key', 30.5, 'value');
Is that PhpRedis would need to detect the float, redirect to PSETEX (along with a millisecond conversion).
PSETEX
127.0.0.1:6379> setex key 30.5 value (error) ERR value is not an integer or out of range
Sorry, something went wrong.
No branches or pull requests
It seems TTL values are typed as integers - https://github.com/phpredis/phpredis/blob/35a7cc09/redis.stub.php#L3066
Since Redis v2.6 the Redis stores all TTL values with milliseconds resolution, so I expect:
$redis->setEx('key', 30.5, 'value');
)PHP float type always accepts an int, even with strict types, so no BC break is implied.
Code like:
could be then written as:
or even
which is shorter and more readable.
The text was updated successfully, but these errors were encountered: