X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/43f30ac0f9bcc4a7afb06136a8dfe5b703be7935..49128f0b9da725de992e427fa341a837bcc2991b:/doc/ExpireCommand.html diff --git a/doc/ExpireCommand.html b/doc/ExpireCommand.html index d5baeca2..a3dbbe5b 100644 --- a/doc/ExpireCommand.html +++ b/doc/ExpireCommand.html @@ -16,7 +16,7 @@
1: the timeout was set. 0: the timeout was not set since the key already has an associated timeout, or the key does not exist. +
+redis> set a 100 +OK +redis> expire a 360 +(integer) 1 +redis> incr a +(integer) 1- +I set a key to the value of 100, then set an expire of 360 seconds, and then incremented the key (before the 360 timeout expired of course). The obvious result would be: 101, instead the key is set to the value of 1. Why? +There is a very important reason involving the Append Only File and Replication. Let's rework a bit hour example adding the notion of time to the mix: +
+SET a 100 +EXPIRE a 5 +... wait 10 seconds ... +INCR a ++Imagine a Redis version that does not implement the "Delete keys with an expire set on write operation" semantic. +Running the above example with the 10 seconds pause will lead to 'a' being set to the value of 1, as it no longer exists when INCR is called 10 seconds later.