Skip to content
This repository has been archived by the owner on Sep 11, 2019. It is now read-only.

Mutating operations incorrectly clear expiry #2

Closed
bmerry opened this issue Nov 12, 2017 · 1 comment
Closed

Mutating operations incorrectly clear expiry #2

bmerry opened this issue Nov 12, 2017 · 1 comment

Comments

@bmerry
Copy link

bmerry commented Nov 12, 2017

A number of operations modify an existing value, then assign back to self._db, which has the side-effect of clearing the expiry time. According to the redis documentation, only operations that completely replace a key (rather than modifying it) clear the expiry. I haven't written any tests yet, but looking at the code, it is probably at least

  • decr, incr, incrby, incrbyfloat
  • setbit
  • ltrim
  • rpoplpush

Some other operations where I'm not sure what redis will do

  • getset
  • rename, renamenx
@bmerry
Copy link
Author

bmerry commented Nov 12, 2017

rename is affected (redis carries the expiry time with the rename), and setrange is also affected. getset is not affected: redis clears the expiry.

bmerry added a commit that referenced this issue Nov 12, 2017
A new setx function is added to _StrKeyDict that updates the value but
preserves the existing expiry time. This is used by mutating operations
that replace the value rather than mutating it in-place (which is
impossible for strings, and happens not to be done in some other
cases).

Fixes #2.
@bmerry bmerry closed this as completed in #3 Nov 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant