8000 SET PX/EX 0 sets a key silently without expiration · Issue #640 · phpredis/phpredis · GitHub
[go: up one dir, main page]

Skip to content
SET PX/EX 0 sets a key silently without expiration #640
Closed
@malkusch

Description

@malkusch

In redis-cli I try this:

127.0.0.1:6379> set foo bar ex 0
(error) ERR invalid expire time in set

I would expect the same with the API, but

$redis->set("foo", "bar", ["ex" => 0]);

returns true plus I see that foo exists without a ttl:

127.0.0.1:6379> ttl foo
(integer) -1

Why is this a serious issue? The TTL is used in the propagated RedLock algorithm and guarantees liveness. Now assume a PHP developer did by some mistake put something like "2280s" as ttl parameter (I saw that really). As nothing blows up he will assume everything works as expected, but the database will slowly degrade with unreleased locks.

So I would expect that above mentioned API call would throw an exception, return false or what ever, but in no case silently set the key without an expiration.

Metadata

Metadata

Assignees

No one assigned

    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

      0