]> git.saurik.com Git - redis.git/blob - tests/unit/expire.tcl
make sure the value to insert is string encoded
[redis.git] / tests / unit / expire.tcl
1 start_server {tags {"expire"}} {
2 test {EXPIRE - don't set timeouts multiple times} {
3 r set x foobar
4 set v1 [r expire x 5]
5 set v2 [r ttl x]
6 set v3 [r expire x 10]
7 set v4 [r ttl x]
8 list $v1 $v2 $v3 $v4
9 } {1 5 0 5}
10
11 test {EXPIRE - It should be still possible to read 'x'} {
12 r get x
13 } {foobar}
14
15 tags {"slow"} {
16 test {EXPIRE - After 6 seconds the key should no longer be here} {
17 after 6000
18 list [r get x] [r exists x]
19 } {{} 0}
20 }
21
22 test {EXPIRE - Delete on write policy} {
23 r del x
24 r lpush x foo
25 r expire x 1000
26 r lpush x bar
27 r lrange x 0 -1
28 } {bar}
29
30 test {EXPIREAT - Check for EXPIRE alike behavior} {
31 r del x
32 r set x foo
33 r expireat x [expr [clock seconds]+15]
34 r ttl x
35 } {1[345]}
36
37 test {SETEX - Set + Expire combo operation. Check for TTL} {
38 r setex x 12 test
39 r ttl x
40 } {1[012]}
41
42 test {SETEX - Check value} {
43 r get x
44 } {test}
45
46 test {SETEX - Overwrite old key} {
47 r setex y 1 foo
48 r get y
49 } {foo}
50
51 tags {"slow"} {
52 test {SETEX - Wait for the key to expire} {
53 after 3000
54 r get y
55 } {}
56 }
57
58 test {SETEX - Wrong time parameter} {
59 catch {r setex z -10 foo} e
60 set _ $e
61 } {*invalid expire*}
62 }