Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Float values for EX/PX cause "EXPIRE can't be < 1" warnings #2448

@Danny-Smart

Description

@Danny-Smart

With an open connection to Redis, a set command using "EX" or "PX" that has a corresponding float value for TTL will raise the PHP Warning "EXPIRE can't be < 1" even when the value of the float is greater than 1.

I understand that Redis requires an integer for expiry/TTL, but the extension should either raise a type error when a float is passed or convert float values to integer internally. As it is, the warning is entirely misleading.

Expected behaviour

The following command should return true or a error should be raised for the invalid ttl type
$redis->set("my_key", true, ["NX", "EX" => 300.0]);

Actual behaviour

The following warning is raised:
E_WARNING: Redis::set(): EXPIRE can't be < 1

I'm seeing this behaviour on

  • OS: Debian (docker container)
  • Redis: 7.0 (though it's not interacting with Redis so this is irrelevant)
  • PHP: 8.2.9
  • phpredis: latest (installed through pecl)

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions