Skip to content

[NEW] Suggestion: support IF* in [P]EXPIRE (and possible PERSIST) #14505

@mgravell

Description

@mgravell

Scenario: extending the lifetime of a known value, in particular for "lock" and "cache" scenarios.

In a lock use-case, of a long-running operation: it is often desirable to take a relatively short lock duration, and extend it periodically - so that in the event of the task being interrupted, the lock is released without too long a delay. This requires an "if I still have it" check, typically via Lua (but WATCH, GET, MULTI, PEXPIRE, {EXEC|ABORT} is also an option).

The new CAS SET does allow this for this, but requires passing the value even when you don't want to update it, for example: SET foo expected_value EX new_ttl IFEQ expected_value or similar with IFDEQ. Since lock tokens are usually short, this is probably perfectly acceptable; however: for cache values (which has similar life extension scenarios, think "sliding expiration"), we should anticipate that the value may be larger, making this undesirable. Perhaps PEXPIRE foo new_ttl IFDEQ expected_hash is a better mechanism.

As such, it would be a nice convenience feature to perform value-checked TTL maintenance without reassigning the value, in-line with the new CAS/CAD features.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions