]>
Commit | Line | Data |
---|---|---|
7f7499ee | 1 | start_server {tags {"expire"}} { |
2c572622 | 2 | test {EXPIRE - set timeouts multiple times} { |
98578b57 PN |
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] | |
2c572622 | 8 | r expire x 4 |
98578b57 | 9 | list $v1 $v2 $v3 $v4 |
bf1379c8 | 10 | } {1 [45] 1 10} |
98578b57 PN |
11 | |
12 | test {EXPIRE - It should be still possible to read 'x'} { | |
13 | r get x | |
14 | } {foobar} | |
15 | ||
6b6f101c PN |
16 | tags {"slow"} { |
17 | test {EXPIRE - After 6 seconds the key should no longer be here} { | |
18 | after 6000 | |
19 | list [r get x] [r exists x] | |
20 | } {{} 0} | |
21 | } | |
98578b57 | 22 | |
2c572622 | 23 | test {EXPIRE - write on expire should work} { |
98578b57 PN |
24 | r del x |
25 | r lpush x foo | |
26 | r expire x 1000 | |
27 | r lpush x bar | |
28 | r lrange x 0 -1 | |
2c572622 | 29 | } {bar foo} |
98578b57 PN |
30 | |
31 | test {EXPIREAT - Check for EXPIRE alike behavior} { | |
32 | r del x | |
33 | r set x foo | |
34 | r expireat x [expr [clock seconds]+15] | |
35 | r ttl x | |
36 | } {1[345]} | |
37 | ||
38 | test {SETEX - Set + Expire combo operation. Check for TTL} { | |
39 | r setex x 12 test | |
40 | r ttl x | |
41 | } {1[012]} | |
42 | ||
43 | test {SETEX - Check value} { | |
44 | r get x | |
45 | } {test} | |
46 | ||
47 | test {SETEX - Overwrite old key} { | |
48 | r setex y 1 foo | |
49 | r get y | |
50 | } {foo} | |
51 | ||
afbf5914 PN |
52 | tags {"slow"} { |
53 | test {SETEX - Wait for the key to expire} { | |
54 | after 3000 | |
55 | r get y | |
56 | } {} | |
57 | } | |
98578b57 PN |
58 | |
59 | test {SETEX - Wrong time parameter} { | |
60 | catch {r setex z -10 foo} e | |
61 | set _ $e | |
62 | } {*invalid expire*} | |
1fb4e8de | 63 | |
64 | test {PERSIST can undo an EXPIRE} { | |
65 | r set x foo | |
66 | r expire x 50 | |
67 | list [r ttl x] [r persist x] [r ttl x] [r get x] | |
68 | } {50 1 -1 foo} | |
69 | ||
70 | test {PERSIST returns 0 against non existing or non volatile keys} { | |
71 | r set x foo | |
72 | list [r persist foo] [r persist nokeyatall] | |
73 | } {0 0} | |
98578b57 | 74 | } |