]> git.saurik.com Git - redis.git/blob - tests/unit/cas.tcl
SORT with STORE removes key if result is empty. This fixes issue #227.
[redis.git] / tests / unit / cas.tcl
1 start_server {tags {"cas"}} {
2 test {EXEC works on WATCHed key not modified} {
3 r watch x y z
4 r watch k
5 r multi
6 r ping
7 r exec
8 } {PONG}
9
10 test {EXEC fail on WATCHed key modified (1 key of 1 watched)} {
11 r set x 30
12 r watch x
13 r set x 40
14 r multi
15 r ping
16 r exec
17 } {}
18
19 test {EXEC fail on WATCHed key modified (1 key of 5 watched)} {
20 r set x 30
21 r watch a b x k z
22 r set x 40
23 r multi
24 r ping
25 r exec
26 } {}
27
28 test {EXEC fail on WATCHed key modified by SORT with STORE even if the result is empty} {
29 r flushdb
30 r lpush foo bar
31 r watch foo
32 r sort emptylist store foo
33 r multi
34 r ping
35 r exec
36 } {}
37
38 test {After successful EXEC key is no longer watched} {
39 r set x 30
40 r watch x
41 r multi
42 r ping
43 r exec
44 r set x 40
45 r multi
46 r ping
47 r exec
48 } {PONG}
49
50 test {After failed EXEC key is no longer watched} {
51 r set x 30
52 r watch x
53 r set x 40
54 r multi
55 r ping
56 r exec
57 r set x 40
58 r multi
59 r ping
60 r exec
61 } {PONG}
62
63 test {It is possible to UNWATCH} {
64 r set x 30
65 r watch x
66 r set x 40
67 r unwatch
68 r multi
69 r ping
70 r exec
71 } {PONG}
72
73 test {UNWATCH when there is nothing watched works as expected} {
74 r unwatch
75 } {OK}
76
77 test {FLUSHALL is able to touch the watched keys} {
78 r set x 30
79 r watch x
80 r flushall
81 r multi
82 r ping
83 r exec
84 } {}
85
86 test {FLUSHALL does not touch non affected keys} {
87 r del x
88 r watch x
89 r flushall
90 r multi
91 r ping
92 r exec
93 } {PONG}
94
95 test {FLUSHDB is able to touch the watched keys} {
96 r set x 30
97 r watch x
98 r flushdb
99 r multi
100 r ping
101 r exec
102 } {}
103
104 test {FLUSHDB does not touch non affected keys} {
105 r del x
106 r watch x
107 r flushdb
108 r multi
109 r ping
110 r exec
111 } {PONG}
112
113 test {WATCH is able to remember the DB a key belongs to} {
114 r select 5
115 r set x 30
116 r watch x
117 r select 1
118 r set x 10
119 r select 5
120 r multi
121 r ping
122 r exec
123 } {PONG}
124
125 test {WATCH will consider touched keys target of EXPIRE} {
126 r del x
127 r set x foo
128 r watch x
129 r expire x 10
130 r multi
131 r ping
132 r exec
133 } {}
134
135 test {WATCH will not consider touched expired keys} {
136 r del x
137 r set x foo
138 r expire x 1
139 r watch x
140 after 1100
141 r multi
142 r ping
143 r exec
144 } {PONG}
145
146 test {DISCARD should clear the WATCH dirty flag on the client} {
147 r watch x
148 r set x 10
149 r multi
150 r discard
151 r multi
152 r incr x
153 r exec
154 } {11}
155
156 test {DISCARD should UNWATCH all the keys} {
157 r watch x
158 r set x 10
159 r multi
160 r discard
161 r set x 10
162 r multi
163 r incr x
164 r exec
165 } {11}
166 }