X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/7f7499eeace8f69aeb32a4e92554eb0b144e8226..890a2ed989274cb09b5cde1def3935e110ec3cb9:/tests/unit/expire.tcl diff --git a/tests/unit/expire.tcl b/tests/unit/expire.tcl index 6b2fe747..6f16ed58 100644 --- a/tests/unit/expire.tcl +++ b/tests/unit/expire.tcl @@ -1,29 +1,32 @@ start_server {tags {"expire"}} { - test {EXPIRE - don't set timeouts multiple times} { + test {EXPIRE - set timeouts multiple times} { r set x foobar set v1 [r expire x 5] set v2 [r ttl x] set v3 [r expire x 10] set v4 [r ttl x] + r expire x 4 list $v1 $v2 $v3 $v4 - } {1 5 0 5} + } {1 5 1 10} test {EXPIRE - It should be still possible to read 'x'} { r get x } {foobar} - test {EXPIRE - After 6 seconds the key should no longer be here} { - after 6000 - list [r get x] [r exists x] - } {{} 0} + tags {"slow"} { + test {EXPIRE - After 6 seconds the key should no longer be here} { + after 6000 + list [r get x] [r exists x] + } {{} 0} + } - test {EXPIRE - Delete on write policy} { + test {EXPIRE - write on expire should work} { r del x r lpush x foo r expire x 1000 r lpush x bar r lrange x 0 -1 - } {bar} + } {bar foo} test {EXPIREAT - Check for EXPIRE alike behavior} { r del x @@ -46,13 +49,26 @@ start_server {tags {"expire"}} { r get y } {foo} - test {SETEX - Wait for the key to expire} { - after 3000 - r get y - } {} + tags {"slow"} { + test {SETEX - Wait for the key to expire} { + after 3000 + r get y + } {} + } test {SETEX - Wrong time parameter} { catch {r setex z -10 foo} e set _ $e } {*invalid expire*} + + test {PERSIST can undo an EXPIRE} { + r set x foo + r expire x 50 + list [r ttl x] [r persist x] [r ttl x] [r get x] + } {50 1 -1 foo} + + test {PERSIST returns 0 against non existing or non volatile keys} { + r set x foo + list [r persist foo] [r persist nokeyatall] + } {0 0} }