blib/lib/Async/Redis/KeyExtractor.pm

filter: Statementstmt 24.2% 69 / 285 Branchbran 33.3% 20 / 60 Conditioncond 29.6% 8 / 27 MC/DCmcdc 23.5% 4 / 17 Subroutinesub 10.6% 21 / 197 Podpod 0.0% 0 / 2 totaltotal 20.7% 122 / 588 CC 45 SCAR 14.3
CC
45
Cov
26%
_keys_for_zinter
20.0
_keys_for_zinterstore
20.0
_keys_for_sintercard
20.0
CRAP 4.2
« blib/lib/Async/Redis/Script.pm ↑ Summary blib/lib/Async/Redis/Error/Redis.pm »
1 # lib/Future/IO/Redis/KeyExtractor.pm
2 package Async::Redis::KeyExtractor;
3  
4 92 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 92 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 92 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # Key position handlers for each command
9 # Generated from commands.json key_specs + manual overrides
10 our %KEY_POSITIONS = (
11 # Simple single-key commands (first arg is key)
12 2 ▶ 'GET' => sub { (0) },
Subroutine __ANON__: called CC=1 SCAR=0.0
13 2 ▶ 'SET' => sub { (0) },
Subroutine __ANON__: called CC=1 SCAR=0.0
14 0 ▶ 'GETEX' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
15 0 ▶ 'GETDEL' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
16 0 ▶ 'GETSET' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
17 0 ▶ 'APPEND' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 0 ▶ 'STRLEN' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
19 0 ▶ 'SETEX' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
20 0 ▶ 'PSETEX' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 0 ▶ 'SETNX' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 0 ▶ 'SETRANGE' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 0 ▶ 'GETRANGE' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
24 0 ▶ 'INCR' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
25 0 ▶ 'DECR' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 0 ▶ 'INCRBY' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
27 0 ▶ 'DECRBY' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 0 ▶ 'INCRBYFLOAT' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
29  
30 # Multi-key commands (all args are keys)
31 2 ▶ 'MGET' => sub { (0 .. $#_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
32 2 ▶ 'DEL' => sub { (0 .. $#_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
33 0 ▶ 'UNLINK' => sub { (0 .. $#_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
34 1 ▶ 'EXISTS' => sub { (0 .. $#_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
35 0 ▶ 'TOUCH' => sub { (0 .. $#_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
36 0 ▶ 'WATCH' => sub { (0 .. $#_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
37  
38 # MSET: even indices are keys
39 2 ▶ 'MSET' => sub { grep { $_ % 2 == 0 } (0 .. $#_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
40 0 ▶ 'MSETNX' => sub { grep { $_ % 2 == 0 } (0 .. $#_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
41  
42 # Hash commands (first arg is key)
43 1 ▶ 'HSET' => sub { (0) },
Subroutine __ANON__: called CC=1 SCAR=0.0
44 1 ▶ 'HGET' => sub { (0) },
Subroutine __ANON__: called CC=1 SCAR=0.0
45 0 ▶ 'HDEL' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
46 0 ▶ 'HEXISTS' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
47 0 ▶ 'HLEN' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
48 0 ▶ 'HKEYS' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
49 0 ▶ 'HVALS' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
50 1 ▶ 'HGETALL' => sub { (0) },
Subroutine __ANON__: called CC=1 SCAR=0.0
51 0 ▶ 'HMSET' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
52 0 ▶ 'HMGET' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 0 ▶ 'HSETNX' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
54 0 ▶ 'HINCRBY' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
55 0 ▶ 'HINCRBYFLOAT' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
56 0 ▶ 'HSCAN' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
57 0 ▶ 'HRANDFIELD' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
58  
59 # List commands (first arg is key)
60 1 ▶ 'LPUSH' => sub { (0) },
Subroutine __ANON__: called CC=1 SCAR=0.0
61 0 ▶ 'RPUSH' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
62 0 ▶ 'LPOP' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
63 0 ▶ 'RPOP' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
64 0 ▶ 'LLEN' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
65 1 ▶ 'LRANGE' => sub { (0) },
Subroutine __ANON__: called CC=1 SCAR=0.0
66 0 ▶ 'LINDEX' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
67 0 ▶ 'LSET' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
68 0 ▶ 'LREM' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
69 0 ▶ 'LINSERT' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
70 0 ▶ 'LTRIM' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
71 0 ▶ 'LPOS' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
72 0 ▶ 'LPUSHX' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
73 0 ▶ 'RPUSHX' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
74  
75 # Blocking list commands (first arg is key, or multiple keys)
76 'BLPOP' => \&_keys_for_blocking_list,
77 'BRPOP' => \&_keys_for_blocking_list,
78 0 ▶ 'BLMOVE' => sub { (0, 1) }, # source and dest
Subroutine __ANON__: not called CC=1 SCAR=6.9
79 0 ▶ 'BRPOPLPUSH' => sub { (0, 1) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
80 0 ▶ 'LMOVE' => sub { (0, 1) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
81  
82 # Set commands (first arg is key)
83 0 ▶ 'SADD' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
84 0 ▶ 'SREM' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
85 0 ▶ 'SMEMBERS' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
86 0 ▶ 'SISMEMBER' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
87 0 ▶ 'SMISMEMBER' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
88 0 ▶ 'SCARD' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
89 0 ▶ 'SPOP' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
90 0 ▶ 'SRANDMEMBER' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
91 0 ▶ 'SSCAN' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
92 0 ▶ 'SMOVE' => sub { (0, 1) }, # source and dest
Subroutine __ANON__: not called CC=1 SCAR=6.9
93 0 ▶ 'SINTER' => sub { (0 .. $#_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
94 0 ▶ 'SUNION' => sub { (0 .. $#_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
95 0 ▶ 'SDIFF' => sub { (0 .. $#_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
96 0 ▶ 'SINTERSTORE' => sub { (0 .. $#_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
97 0 ▶ 'SUNIONSTORE' => sub { (0 .. $#_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
98 0 ▶ 'SDIFFSTORE' => sub { (0 .. $#_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
99 'SINTERCARD' => \&_keys_for_sintercard,
100  
101 # Sorted set commands (first arg is key)
102 0 ▶ 'ZADD' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
103 0 ▶ 'ZREM' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
104 0 ▶ 'ZSCORE' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
105 0 ▶ 'ZRANK' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
106 0 ▶ 'ZREVRANK' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
107 0 ▶ 'ZRANGE' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
108 0 ▶ 'ZREVRANGE' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
109 0 ▶ 'ZRANGEBYSCORE' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
110 0 ▶ 'ZREVRANGEBYSCORE' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
111 0 ▶ 'ZCARD' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
112 0 ▶ 'ZCOUNT' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
113 0 ▶ 'ZINCRBY' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
114 0 ▶ 'ZLEXCOUNT' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
115 0 ▶ 'ZRANGEBYLEX' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
116 0 ▶ 'ZREVRANGEBYLEX' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
117 0 ▶ 'ZPOPMIN' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
118 0 ▶ 'ZPOPMAX' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
119 'BZPOPMIN' => \&_keys_for_blocking_list,
120 'BZPOPMAX' => \&_keys_for_blocking_list,
121 0 ▶ 'ZRANGESTORE' => sub { (0, 1) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
122 'ZINTER' => \&_keys_for_zinter,
123 'ZUNION' => \&_keys_for_zinter,
124 'ZDIFF' => \&_keys_for_zinter,
125 'ZINTERSTORE' => \&_keys_for_zinterstore,
126 'ZUNIONSTORE' => \&_keys_for_zinterstore,
127 'ZDIFFSTORE' => \&_keys_for_zinterstore,
128 0 ▶ 'ZSCAN' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
129 0 ▶ 'ZRANDMEMBER' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
130 'ZMPOP' => \&_keys_for_zmpop,
131 'BZMPOP' => \&_keys_for_bzmpop,
132  
133 # Key commands
134 0 ▶ 'EXPIRE' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
135 0 ▶ 'EXPIREAT' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
136 0 ▶ 'PEXPIRE' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
137 0 ▶ 'PEXPIREAT' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
138 0 ▶ 'TTL' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
139 0 ▶ 'PTTL' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
140 0 ▶ 'PERSIST' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
141 0 ▶ 'TYPE' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
142 0 ▶ 'RENAME' => sub { (0, 1) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
143 0 ▶ 'RENAMENX' => sub { (0, 1) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
144 0 ▶ 'COPY' => sub { (0, 1) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
145 0 ▶ 'DUMP' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
146 0 ▶ 'RESTORE' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
147 0 ▶ 'EXPIRETIME' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
148 0 ▶ 'PEXPIRETIME' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
149 'OBJECT' => \&_keys_for_object,
150  
151 # EVAL/EVALSHA - dynamic based on numkeys
152 'EVAL' => \&_keys_for_eval,
153 'EVALSHA' => \&_keys_for_eval,
154 'EVALSHA_RO' => \&_keys_for_eval,
155 'EVAL_RO' => \&_keys_for_eval,
156 'FCALL' => \&_keys_for_eval,
157 'FCALL_RO' => \&_keys_for_eval,
158  
159 # HyperLogLog commands
160 0 ▶ 'PFADD' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
161 0 ▶ 'PFCOUNT' => sub { (0 .. $#_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
162 0 ▶ 'PFMERGE' => sub { (0 .. $#_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
163  
164 # Bit commands (first arg is key)
165 0 ▶ 'GETBIT' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
166 0 ▶ 'SETBIT' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
167 0 ▶ 'BITCOUNT' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
168 0 ▶ 'BITPOS' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
169  
170 # Hash length
171 0 ▶ 'HSTRLEN' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
172  
173 # Sorted set multi-score lookup
174 0 ▶ 'ZMSCORE' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
175  
176 # BITOP - skip operation arg
177 1 ▶ 'BITOP' => sub { (1 .. $#_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
178  
179 # Stream commands
180 0 ▶ 'XADD' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
181 0 ▶ 'XLEN' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
182 0 ▶ 'XRANGE' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
183 0 ▶ 'XREVRANGE' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
184 'XREAD' => \&_keys_for_xread,
185 'XREADGROUP' => \&_keys_for_xread,
186 'XINFO' => \&_keys_for_xinfo,
187 'XGROUP' => \&_keys_for_xgroup,
188 0 ▶ 'XACK' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
189 0 ▶ 'XCLAIM' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
190 0 ▶ 'XAUTOCLAIM' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
191 0 ▶ 'XPENDING' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
192 0 ▶ 'XTRIM' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
193 0 ▶ 'XDEL' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
194 0 ▶ 'XSETID' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
195  
196 # Geo commands
197 0 ▶ 'GEOADD' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
198 0 ▶ 'GEOPOS' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
199 0 ▶ 'GEODIST' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
200 0 ▶ 'GEOHASH' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
201 'GEORADIUS' => \&_keys_for_georadius,
202 'GEORADIUSBYMEMBER' => \&_keys_for_georadius,
203 0 ▶ 'GEOSEARCH' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
204 0 ▶ 'GEOSEARCHSTORE' => sub { (0, 1) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
205  
206 # MIGRATE - special handling
207 'MIGRATE' => \&_keys_for_migrate,
208  
209 # SORT
210 0 ▶ 'SORT' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
211 0 ▶ 'SORT_RO' => sub { (0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
212  
213 # SCAN commands return patterns, not keys - first arg is key for HSCAN/SSCAN/ZSCAN
214 0 ▶ 'SCAN' => sub { () }, # No key, cursor-based
Subroutine __ANON__: not called CC=1 SCAR=6.9
215  
216 # Pub/Sub - channels, not keys
217 0 ▶ 'PUBLISH' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
218 0 ▶ 'SUBSCRIBE' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
219 0 ▶ 'UNSUBSCRIBE' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
220 0 ▶ 'PSUBSCRIBE' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
221 0 ▶ 'PUNSUBSCRIBE' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
222  
223 # Server commands - no keys
224 0 ▶ 'PING' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
225 0 ▶ 'ECHO' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
226 0 ▶ 'AUTH' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
227 0 ▶ 'SELECT' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
228 0 ▶ 'INFO' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
229 0 ▶ 'DBSIZE' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
230 0 ▶ 'FLUSHDB' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
231 0 ▶ 'FLUSHALL' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
232 0 ▶ 'SAVE' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
233 0 ▶ 'BGSAVE' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
234 0 ▶ 'LASTSAVE' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
235 0 ▶ 'TIME' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
236 0 ▶ 'CONFIG' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
237 0 ▶ 'CLIENT' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
238 0 ▶ 'SLOWLOG' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
239 0 ▶ 'DEBUG' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
240 0 ▶ 'MEMORY' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
241 0 ▶ 'MODULE' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
242 0 ▶ 'ACL' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
243 0 ▶ 'COMMAND' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
244 0 ▶ 'MULTI' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
245 0 ▶ 'EXEC' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
246 0 ▶ 'DISCARD' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
247 0 ▶ 'UNWATCH' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
248 0 ▶ 'SCRIPT' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
249 0 ▶ 'CLUSTER' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
250 0 ▶ 'READONLY' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
251 0 ▶ 'READWRITE' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
252 0 ▶ 'WAIT' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
253 0 ▶ 'KEYS' => sub { () }, # Pattern, not literal key
Subroutine __ANON__: not called CC=1 SCAR=6.9
254 0 ▶ 'RANDOMKEY' => sub { () },
Subroutine __ANON__: not called CC=1 SCAR=6.9
255 92 );
256  
257 # Fallback patterns for unknown commands
258 our @FALLBACK_PATTERNS = (
259 # Hash commands: first arg is key
260 0 ▶ [ qr/^H(?:SET|GET|DEL|EXISTS|INCR|LEN|KEYS|VALS|GETALL|SCAN|MGET|MSET)/i, sub { (0) } ],
Subroutine __ANON__: not called CC=1 SCAR=6.9
261  
262 # List commands: first arg is key
263 0 ▶ [ qr/^[LR](?:PUSH|POP|LEN|INDEX|RANGE|SET|TRIM|REM|INSERT|POS)/i, sub { (0) } ],
Subroutine __ANON__: not called CC=1 SCAR=6.9
264  
265 # Set commands: first arg is key
266 0 ▶ [ qr/^S(?:ADD|REM|MEMBERS|ISMEMBER|CARD|POP|RANDMEMBER|SCAN)/i, sub { (0) } ],
Subroutine __ANON__: not called CC=1 SCAR=6.9
267  
268 # Sorted set commands: first arg is key
269 0 ▶ [ qr/^Z(?:ADD|REM|SCORE|RANK|RANGE|CARD|COUNT|INCRBY|SCAN)/i, sub { (0) } ],
Subroutine __ANON__: not called CC=1 SCAR=6.9
270  
271 # Generic fallback: assume first arg is key for unknown X* commands (streams)
272 0 ▶ [ qr/^X/i, sub { (0) } ],
Subroutine __ANON__: not called CC=1 SCAR=1.2
273 );
274  
275 26 ▶sub extract_key_indices {
Subroutine extract_key_indices: called CC=5 SCAR=16.5
Pod undocumented
276 26 my ($command, @args) = @_;
277 26 $command = uc($command);
278  
279 # Check explicit handlers
280 26 ▶ if (my $handler = $KEY_POSITIONS{$command}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $handler = $Async::Redis::KeyExtractor::KEY_POSITIONS{$command}) 25 1 26
281 25 return $handler->(@args);
282 }
283  
284 # Try fallback patterns
285 1 for my $pattern (@FALLBACK_PATTERNS) {
286 5 ▶ if ($command =~ $pattern->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($command =~ /$pattern->[0]/u) 0 5 5
287 0 return $pattern->[1]->(@args);
288 }
289 }
290  
291 # Unknown command - no prefixing, warn in debug mode
292 1 ▶ warn "Unknown command '$command': key prefixing skipped" if $ENV{REDIS_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"REDIS_DEBUG"} 0 1 1
293 1 return ();
294 }
295  
296 6 ▶sub apply_prefix {
Subroutine apply_prefix: called CC=5 SCAR=16.1
Pod undocumented
297 6 my ($prefix, $command, @args) = @_;
298 6 ▶ return @args unless defined $prefix && $prefix ne '';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $prefix and $prefix ne "" 2 4 6
Condition100%3/3
defined $prefix and $prefix ne ""
!ll&&!rl&&r
114
MC/DC100%2/2
defined $prefix and $prefix ne ""
defined $prefix $prefix ne ""
Truth table100%3/3
A and B
A= defined $prefixB= $prefix ne ""
ABresult
0X0
100
111
299  
300 4 my @key_indices = extract_key_indices($command, @args);
301 4 for my $i (@key_indices) {
302 7 ▶ next if $i > $#args; # Safety check
Branch: 1 branch
BranchTrueFalseTotal
if $i > $#args 0 7 7
303 7 $args[$i] = $prefix . $args[$i];
304 }
305  
306 4 return @args;
307 }
308  
309 # --- Custom handlers for complex commands ---
310  
311 3 ▶sub _keys_for_eval {
Subroutine _keys_for_eval: called CC=5 SCAR=17.0
312 3 my (@args) = @_;
313 # EVAL script numkeys [key ...] [arg ...]
314 # EVALSHA sha1 numkeys [key ...] [arg ...]
315 3 ▶ return () unless @args >= 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @args >= 2 0 3 3
316  
317 3 my $numkeys = $args[1];
318 3 ▶ return () unless defined $numkeys && $numkeys =~ /^\d+$/ && $numkeys > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $numkeys and $numkeys =~ /^\d+$/u and $numkeys > 0 1 2 3
Condition50%3/6
defined $numkeys and $numkeys =~ /^\d+$/u and $numkeys > 0
!ll&&!rl&&r
012
defined $numkeys and $numkeys =~ /^\d+$/u
!ll&&!rl&&r
003
MC/DC33%1/3
defined $numkeys and $numkeys =~ /^\d+$/u and $numkeys > 0
defined $numkeys $numkeys =~ /^\d+$/u $numkeys > 0
Truth table50%2/4
A and B and C
A= defined $numkeysB= $numkeys =~ /^\d+$/uC= $numkeys > 0
ABCresult
0XX0
10X0
1100
1111
319  
320 # Keys are at indices 2 through 2+numkeys-1
321 2 return (2 .. 2 + $numkeys - 1);
322 }
323  
324 2 ▶sub _keys_for_xread {
Subroutine _keys_for_xread: called CC=5 SCAR=16.2
325 2 my (@args) = @_;
326  
327 # Find STREAMS keyword
328 2 my $streams_idx;
329 2 for my $i (0 .. $#args) {
330 6 ▶ if (uc($args[$i]) eq 'STREAMS') {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $args[$i] eq "STREAMS") 2 4 6
331 2 $streams_idx = $i;
332 2 last;
333 }
334 }
335 2 ▶ return () unless defined $streams_idx;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $streams_idx 0 2 2
336  
337 # Keys are between STREAMS and the IDs
338 # Number of streams = number of IDs = (remaining args after STREAMS) / 2
339 2 my $remaining = $#args - $streams_idx;
340 2 my $num_streams = int($remaining / 2);
341  
342 2 ▶ return () unless $num_streams > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $num_streams > 0 0 2 2
343 2 return ($streams_idx + 1 .. $streams_idx + $num_streams);
344 }
345  
346 2 ▶sub _keys_for_migrate {
Subroutine _keys_for_migrate: called CC=5 SCAR=16.1
347 2 my (@args) = @_;
348 2 my @key_indices;
349  
350 # MIGRATE host port key|"" db timeout [COPY] [REPLACE] [AUTH pw] [KEYS k1 k2 ...]
351  
352 # Single key at position 2 (unless empty string for multi-key)
353 2 ▶ if (@args > 2 && $args[2] ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if (@args > 2 and $args[2] ne "") 1 1 2
Condition66%2/3
@args > 2 and $args[2] ne ""
!ll&&!rl&&r
011
MC/DC50%1/2
@args > 2 and $args[2] ne ""
@args > 2 $args[2] ne ""
Truth table66%2/3
A and B
A= @args > 2B= $args[2] ne ""
ABresult
0X0
100
111
354 1 push @key_indices, 2;
355 }
356  
357 # Multi-key after KEYS keyword
358 2 for my $i (0 .. $#args) {
359 11 ▶ if (uc($args[$i]) eq 'KEYS') {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $args[$i] eq "KEYS") 1 10 11
360 1 push @key_indices, ($i + 1 .. $#args);
361 1 last;
362 }
363 }
364  
365 2 return @key_indices;
366 }
367  
368 1 ▶sub _keys_for_object {
Subroutine _keys_for_object: called CC=3 SCAR=11.8
369 1 my (@args) = @_;
370 # OBJECT subcommand [key] [...]
371 1 ▶ return () unless @args >= 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @args >= 2 0 1 1
372  
373 1 my $subcmd = uc($args[0]);
374 # Most OBJECT subcommands take key as second arg
375 1 ▶ if ($subcmd =~ /^(ENCODING|FREQ|IDLETIME|REFCOUNT)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subcmd =~ /^(ENCODING|FREQ|IDLETIME|REFCOUNT)$/u) 1 0 1
376 1 return (1);
377 }
378 0 return ();
379 }
380  
381 0 ▶sub _keys_for_blocking_list {
Subroutine _keys_for_blocking_list: not called CC=2 SCAR=17.9
382 0 my (@args) = @_;
383 # BLPOP key [key ...] timeout
384 # Last arg is timeout, rest are keys
385 0 ▶ return () unless @args >= 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @args >= 2 0 0 0
386 0 return (0 .. $#args - 1);
387 }
388  
389 0 ▶sub _keys_for_zinter {
Subroutine _keys_for_zinter: not called CC=4 SCAR=30.0
390 0 my (@args) = @_;
391 # ZINTER numkeys key [key ...] [WEIGHTS ...] [AGGREGATE ...]
392 0 ▶ return () unless @args >= 1;
Branch: 1 branch
BranchTrueFalseTotal
unless @args >= 1 0 0 0
393 0 my $numkeys = $args[0];
394 0 ▶ return () unless $numkeys =~ /^\d+$/ && $numkeys > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $numkeys =~ /^\d+$/u and $numkeys > 0 0 0 0
Condition0%0/3
$numkeys =~ /^\d+$/u and $numkeys > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$numkeys =~ /^\d+$/u and $numkeys > 0
$numkeys =~ /^\d+$/u $numkeys > 0
Truth table0%0/3
A and B
A= $numkeys =~ /^\d+$/uB= $numkeys > 0
ABresult
0X0
100
111
395 0 return (1 .. $numkeys);
396 }
397  
398 0 ▶sub _keys_for_zinterstore {
Subroutine _keys_for_zinterstore: not called CC=4 SCAR=30.0
399 0 my (@args) = @_;
400 # ZINTERSTORE destination numkeys key [key ...] [WEIGHTS ...] [AGGREGATE ...]
401 0 ▶ return () unless @args >= 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @args >= 2 0 0 0
402 0 my $numkeys = $args[1];
403 0 ▶ return () unless $numkeys =~ /^\d+$/ && $numkeys > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $numkeys =~ /^\d+$/u and $numkeys > 0 0 0 0
Condition0%0/3
$numkeys =~ /^\d+$/u and $numkeys > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$numkeys =~ /^\d+$/u and $numkeys > 0
$numkeys =~ /^\d+$/u $numkeys > 0
Truth table0%0/3
A and B
A= $numkeys =~ /^\d+$/uB= $numkeys > 0
ABresult
0X0
100
111
404 0 return (0, 2 .. 1 + $numkeys); # dest + source keys
405 }
406  
407 0 ▶sub _keys_for_sintercard {
Subroutine _keys_for_sintercard: not called CC=4 SCAR=30.0
408 0 my (@args) = @_;
409 # SINTERCARD numkeys key [key ...] [LIMIT limit]
410 0 ▶ return () unless @args >= 1;
Branch: 1 branch
BranchTrueFalseTotal
unless @args >= 1 0 0 0
411 0 my $numkeys = $args[0];
412 0 ▶ return () unless $numkeys =~ /^\d+$/ && $numkeys > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $numkeys =~ /^\d+$/u and $numkeys > 0 0 0 0
Condition0%0/3
$numkeys =~ /^\d+$/u and $numkeys > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$numkeys =~ /^\d+$/u and $numkeys > 0
$numkeys =~ /^\d+$/u $numkeys > 0
Truth table0%0/3
A and B
A= $numkeys =~ /^\d+$/uB= $numkeys > 0
ABresult
0X0
100
111
413 0 return (1 .. $numkeys);
414 }
415  
416 0 ▶sub _keys_for_zmpop {
Subroutine _keys_for_zmpop: not called CC=4 SCAR=30.0
417 0 my (@args) = @_;
418 # ZMPOP numkeys key [key ...] MIN|MAX [COUNT count]
419 0 ▶ return () unless @args >= 1;
Branch: 1 branch
BranchTrueFalseTotal
unless @args >= 1 0 0 0
420 0 my $numkeys = $args[0];
421 0 ▶ return () unless $numkeys =~ /^\d+$/ && $numkeys > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $numkeys =~ /^\d+$/u and $numkeys > 0 0 0 0
Condition0%0/3
$numkeys =~ /^\d+$/u and $numkeys > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$numkeys =~ /^\d+$/u and $numkeys > 0
$numkeys =~ /^\d+$/u $numkeys > 0
Truth table0%0/3
A and B
A= $numkeys =~ /^\d+$/uB= $numkeys > 0
ABresult
0X0
100
111
422 0 return (1 .. $numkeys);
423 }
424  
425 0 ▶sub _keys_for_bzmpop {
Subroutine _keys_for_bzmpop: not called CC=4 SCAR=30.0
426 0 my (@args) = @_;
427 # BZMPOP timeout numkeys key [key ...] MIN|MAX [COUNT count]
428 0 ▶ return () unless @args >= 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @args >= 2 0 0 0
429 0 my $numkeys = $args[1];
430 0 ▶ return () unless $numkeys =~ /^\d+$/ && $numkeys > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $numkeys =~ /^\d+$/u and $numkeys > 0 0 0 0
Condition0%0/3
$numkeys =~ /^\d+$/u and $numkeys > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$numkeys =~ /^\d+$/u and $numkeys > 0
$numkeys =~ /^\d+$/u $numkeys > 0
Truth table0%0/3
A and B
A= $numkeys =~ /^\d+$/uB= $numkeys > 0
ABresult
0X0
100
111
431 0 return (2 .. 1 + $numkeys);
432 }
433  
434 0 ▶sub _keys_for_xinfo {
Subroutine _keys_for_xinfo: not called CC=3 SCAR=24.8
435 0 my (@args) = @_;
436 # XINFO STREAM key, XINFO GROUPS key, etc.
437 0 ▶ return () unless @args >= 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @args >= 2 0 0 0
438 0 my $subcmd = uc($args[0]);
439 0 ▶ if ($subcmd =~ /^(STREAM|GROUPS|CONSUMERS)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subcmd =~ /^(STREAM|GROUPS|CONSUMERS)$/u) 0 0 0
440 0 return (1);
441 }
442 0 return ();
443 }
444  
445 0 ▶sub _keys_for_xgroup {
Subroutine _keys_for_xgroup: not called CC=3 SCAR=24.8
446 0 my (@args) = @_;
447 # XGROUP CREATE key groupname id, XGROUP DESTROY key groupname, etc.
448 0 ▶ return () unless @args >= 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @args >= 2 0 0 0
449 0 my $subcmd = uc($args[0]);
450 0 ▶ if ($subcmd =~ /^(CREATE|DESTROY|SETID|DELCONSUMER|CREATECONSUMER)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subcmd =~ /^(CREATE|DESTROY|SETID|DELCONSUMER|CREATECONSUMER)$/u) 0 0 0
451 0 return (1);
452 }
453 0 return ();
454 }
455  
456 0 ▶sub _keys_for_georadius {
Subroutine _keys_for_georadius: not called CC=3 SCAR=24.8
457 0 my (@args) = @_;
458 0 my @indices = (0); # First arg is always key
459  
460 # Look for STORE and STOREDIST
461 0 for my $i (0 .. $#args - 1) {
462 0 ▶ if (uc($args[$i]) =~ /^(STORE|STOREDIST)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (uc($args[$i]) =~ /^(STORE|STOREDIST)$/u) 0 0 0
463 0 push @indices, $i + 1;
464 }
465 }
466  
467 0 return @indices;
468 }
469  
470 92 1;
471  
472 __END__
« blib/lib/Async/Redis/Script.pm ↑ Summary blib/lib/Async/Redis/Error/Redis.pm »