Sitelet https://github.com/phpredis/phpredis/issues/2448
Skip to content

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

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions