]>
Commit | Line | Data |
---|---|---|
7f7499ee | 1 | start_server {tags {"cas"}} { |
c20c189d | 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 {After successful EXEC key is no longer watched} { | |
29 | r set x 30 | |
30 | r watch x | |
31 | r multi | |
32 | r ping | |
33 | r exec | |
34 | r set x 40 | |
35 | r multi | |
36 | r ping | |
37 | r exec | |
38 | } {PONG} | |
39 | ||
40 | test {After failed EXEC key is no longer watched} { | |
41 | r set x 30 | |
42 | r watch x | |
43 | r set x 40 | |
44 | r multi | |
45 | r ping | |
46 | r exec | |
47 | r set x 40 | |
48 | r multi | |
49 | r ping | |
50 | r exec | |
51 | } {PONG} | |
52 | ||
53 | test {It is possible to UNWATCH} { | |
54 | r set x 30 | |
55 | r watch x | |
56 | r set x 40 | |
57 | r unwatch | |
58 | r multi | |
59 | r ping | |
60 | r exec | |
61 | } {PONG} | |
62 | ||
63 | test {UNWATCH when there is nothing watched works as expected} { | |
64 | r unwatch | |
65 | } {OK} | |
9b30e1a2 | 66 | |
67 | test {FLUSHALL is able to touch the watched keys} { | |
68 | r set x 30 | |
69 | r watch x | |
70 | r flushall | |
71 | r multi | |
72 | r ping | |
73 | r exec | |
74 | } {} | |
75 | ||
76 | test {FLUSHALL does not touch non affected keys} { | |
77 | r del x | |
78 | r watch x | |
79 | r flushall | |
80 | r multi | |
81 | r ping | |
82 | r exec | |
83 | } {PONG} | |
84 | ||
85 | test {FLUSHDB is able to touch the watched keys} { | |
86 | r set x 30 | |
87 | r watch x | |
88 | r flushdb | |
89 | r multi | |
90 | r ping | |
91 | r exec | |
92 | } {} | |
93 | ||
94 | test {FLUSHDB does not touch non affected keys} { | |
95 | r del x | |
96 | r watch x | |
97 | r flushdb | |
98 | r multi | |
99 | r ping | |
100 | r exec | |
101 | } {PONG} | |
102 | ||
103 | test {WATCH is able to remember the DB a key belongs to} { | |
104 | r select 5 | |
105 | r set x 30 | |
106 | r watch x | |
107 | r select 1 | |
108 | r set x 10 | |
109 | r select 5 | |
110 | r multi | |
111 | r ping | |
112 | r exec | |
113 | } {PONG} | |
b7a8daef | 114 | |
115 | test {WATCH will consider touched keys target of EXPIRE} { | |
116 | r del x | |
117 | r set x foo | |
118 | r watch x | |
119 | r expire x 10 | |
120 | r multi | |
121 | r ping | |
122 | r exec | |
123 | } {} | |
124 | ||
125 | test {WATCH will not consider touched expired keys} { | |
126 | r del x | |
127 | r set x foo | |
128 | r expire x 2 | |
129 | r watch x | |
130 | after 3000 | |
131 | r multi | |
132 | r ping | |
133 | r exec | |
134 | } {PONG} | |
c20c189d | 135 | } |