]> git.saurik.com Git - redis.git/blame - tests/unit/expire.tcl
Merge http://github.com/ngmoco/redis
[redis.git] / tests / unit / expire.tcl
CommitLineData
98578b57
PN
1start_server default.conf {} {
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 test {EXPIRE - After 6 seconds the key should no longer be here} {
16 after 6000
17 list [r get x] [r exists x]
18 } {{} 0}
19
20 test {EXPIRE - Delete on write policy} {
21 r del x
22 r lpush x foo
23 r expire x 1000
24 r lpush x bar
25 r lrange x 0 -1
26 } {bar}
27
28 test {EXPIREAT - Check for EXPIRE alike behavior} {
29 r del x
30 r set x foo
31 r expireat x [expr [clock seconds]+15]
32 r ttl x
33 } {1[345]}
34
35 test {SETEX - Set + Expire combo operation. Check for TTL} {
36 r setex x 12 test
37 r ttl x
38 } {1[012]}
39
40 test {SETEX - Check value} {
41 r get x
42 } {test}
43
44 test {SETEX - Overwrite old key} {
45 r setex y 1 foo
46 r get y
47 } {foo}
48
49 test {SETEX - Wait for the key to expire} {
50 after 3000
51 r get y
52 } {}
53
54 test {SETEX - Wrong time parameter} {
55 catch {r setex z -10 foo} e
56 set _ $e
57 } {*invalid expire*}
58}