forked from andyli029/hiredis-vip
-
Notifications
You must be signed in to change notification settings - Fork 3
/
command.c
1700 lines (1400 loc) · 43.7 KB
/
command.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <ctype.h>
#include <errno.h>
#include "command.h"
#include "hiutil.h"
#include "hiarray.h"
static uint64_t cmd_id = 0; /* command id counter */
/*
* Return true, if the redis command take no key, otherwise
* return false
*/
static int
redis_argz(struct cmd *r)
{
switch (r->type) {
case CMD_REQ_REDIS_PING:
case CMD_REQ_REDIS_QUIT:
return 1;
default:
break;
}
return 0;
}
/*
* Return true, if the redis command accepts no arguments, otherwise
* return false
*/
static int
redis_arg0(struct cmd *r)
{
switch (r->type) {
case CMD_REQ_REDIS_EXISTS:
case CMD_REQ_REDIS_PERSIST:
case CMD_REQ_REDIS_PTTL:
case CMD_REQ_REDIS_SORT:
case CMD_REQ_REDIS_TTL:
case CMD_REQ_REDIS_TYPE:
case CMD_REQ_REDIS_DUMP:
case CMD_REQ_REDIS_DECR:
case CMD_REQ_REDIS_GET:
case CMD_REQ_REDIS_INCR:
case CMD_REQ_REDIS_STRLEN:
case CMD_REQ_REDIS_HGETALL:
case CMD_REQ_REDIS_HKEYS:
case CMD_REQ_REDIS_HLEN:
case CMD_REQ_REDIS_HVALS:
case CMD_REQ_REDIS_LLEN:
case CMD_REQ_REDIS_LPOP:
case CMD_REQ_REDIS_RPOP:
case CMD_REQ_REDIS_SCARD:
case CMD_REQ_REDIS_SMEMBERS:
case CMD_REQ_REDIS_SPOP:
case CMD_REQ_REDIS_ZCARD:
case CMD_REQ_REDIS_PFCOUNT:
case CMD_REQ_REDIS_AUTH:
return 1;
default:
break;
}
return 0;
}
/*
* Return true, if the redis command accepts exactly 1 argument, otherwise
* return false
*/
static int
redis_arg1(struct cmd *r)
{
switch (r->type) {
case CMD_REQ_REDIS_EXPIRE:
case CMD_REQ_REDIS_EXPIREAT:
case CMD_REQ_REDIS_PEXPIRE:
case CMD_REQ_REDIS_PEXPIREAT:
case CMD_REQ_REDIS_APPEND:
case CMD_REQ_REDIS_DECRBY:
case CMD_REQ_REDIS_GETBIT:
case CMD_REQ_REDIS_GETSET:
case CMD_REQ_REDIS_INCRBY:
case CMD_REQ_REDIS_INCRBYFLOAT:
case CMD_REQ_REDIS_SETNX:
case CMD_REQ_REDIS_HEXISTS:
case CMD_REQ_REDIS_HGET:
case CMD_REQ_REDIS_LINDEX:
case CMD_REQ_REDIS_LPUSHX:
case CMD_REQ_REDIS_RPOPLPUSH:
case CMD_REQ_REDIS_RPUSHX:
case CMD_REQ_REDIS_SISMEMBER:
case CMD_REQ_REDIS_ZRANK:
case CMD_REQ_REDIS_ZREVRANK:
case CMD_REQ_REDIS_ZSCORE:
return 1;
default:
break;
}
return 0;
}
/*
* Return true, if the redis command accepts exactly 2 arguments, otherwise
* return false
*/
static int
redis_arg2(struct cmd *r)
{
switch (r->type) {
case CMD_REQ_REDIS_GETRANGE:
case CMD_REQ_REDIS_PSETEX:
case CMD_REQ_REDIS_SETBIT:
case CMD_REQ_REDIS_SETEX:
case CMD_REQ_REDIS_SETRANGE:
case CMD_REQ_REDIS_HINCRBY:
case CMD_REQ_REDIS_HINCRBYFLOAT:
case CMD_REQ_REDIS_HSET:
case CMD_REQ_REDIS_HSETNX:
case CMD_REQ_REDIS_LRANGE:
case CMD_REQ_REDIS_LREM:
case CMD_REQ_REDIS_LSET:
case CMD_REQ_REDIS_LTRIM:
case CMD_REQ_REDIS_SMOVE:
case CMD_REQ_REDIS_ZCOUNT:
case CMD_REQ_REDIS_ZLEXCOUNT:
case CMD_REQ_REDIS_ZINCRBY:
case CMD_REQ_REDIS_ZREMRANGEBYLEX:
case CMD_REQ_REDIS_ZREMRANGEBYRANK:
case CMD_REQ_REDIS_ZREMRANGEBYSCORE:
case CMD_REQ_REDIS_RESTORE:
return 1;
default:
break;
}
return 0;
}
/*
* Return true, if the redis command accepts exactly 3 arguments, otherwise
* return false
*/
static int
redis_arg3(struct cmd *r)
{
switch (r->type) {
case CMD_REQ_REDIS_LINSERT:
return 1;
default:
break;
}
return 0;
}
/*
* Return true, if the redis command accepts 0 or more arguments, otherwise
* return false
*/
static int
redis_argn(struct cmd *r)
{
switch (r->type) {
case CMD_REQ_REDIS_BITCOUNT:
case CMD_REQ_REDIS_SET:
case CMD_REQ_REDIS_HDEL:
case CMD_REQ_REDIS_HMGET:
case CMD_REQ_REDIS_HMSET:
case CMD_REQ_REDIS_HSCAN:
case CMD_REQ_REDIS_LPUSH:
case CMD_REQ_REDIS_RPUSH:
case CMD_REQ_REDIS_SADD:
case CMD_REQ_REDIS_SDIFF:
case CMD_REQ_REDIS_SDIFFSTORE:
case CMD_REQ_REDIS_SINTER:
case CMD_REQ_REDIS_SINTERSTORE:
case CMD_REQ_REDIS_SREM:
case CMD_REQ_REDIS_SUNION:
case CMD_REQ_REDIS_SUNIONSTORE:
case CMD_REQ_REDIS_SRANDMEMBER:
case CMD_REQ_REDIS_SSCAN:
case CMD_REQ_REDIS_PFADD:
case CMD_REQ_REDIS_PFMERGE:
case CMD_REQ_REDIS_ZADD:
case CMD_REQ_REDIS_ZINTERSTORE:
case CMD_REQ_REDIS_ZRANGE:
case CMD_REQ_REDIS_ZRANGEBYSCORE:
case CMD_REQ_REDIS_ZREM:
case CMD_REQ_REDIS_ZREVRANGE:
case CMD_REQ_REDIS_ZRANGEBYLEX:
case CMD_REQ_REDIS_ZREVRANGEBYSCORE:
case CMD_REQ_REDIS_ZUNIONSTORE:
case CMD_REQ_REDIS_ZSCAN:
return 1;
default:
break;
}
return 0;
}
/*
* Return true, if the redis command is a vector command accepting one or
* more keys, otherwise return false
*/
static int
redis_argx(struct cmd *r)
{
switch (r->type) {
case CMD_REQ_REDIS_MGET:
case CMD_REQ_REDIS_DEL:
return 1;
default:
break;
}
return 0;
}
/*
* Return true, if the redis command is a vector command accepting one or
* more key-value pairs, otherwise return false
*/
static int
redis_argkvx(struct cmd *r)
{
switch (r->type) {
case CMD_REQ_REDIS_MSET:
return 1;
default:
break;
}
return 0;
}
/*
* Return true, if the redis command is either EVAL or EVALSHA. These commands
* have a special format with exactly 2 arguments, followed by one or more keys,
* followed by zero or more arguments (the documentation online seems to suggest
* that at least one argument is required, but that shouldn't be the case).
*/
static int
redis_argeval(struct cmd *r)
{
switch (r->type) {
case CMD_REQ_REDIS_EVAL:
case CMD_REQ_REDIS_EVALSHA:
return 1;
default:
break;
}
return 0;
}
/*
* Reference: http://redis.io/topics/protocol
*
* Redis >= 1.2 uses the unified protocol to send requests to the Redis
* server. In the unified protocol all the arguments sent to the server
* are binary safe and every request has the following general form:
*
* *<number of arguments> CR LF
* $<number of bytes of argument 1> CR LF
* <argument data> CR LF
* ...
* $<number of bytes of argument N> CR LF
* <argument data> CR LF
*
* Before the unified request protocol, redis protocol for requests supported
* the following commands
* 1). Inline commands: simple commands where arguments are just space
* separated strings. No binary safeness is possible.
* 2). Bulk commands: bulk commands are exactly like inline commands, but
* the last argument is handled in a special way in order to allow for
* a binary-safe last argument.
*
* only supports the Redis unified protocol for requests.
*/
void
redis_parse_cmd(struct cmd *r)
{
int len;
char *p, *m, *token = NULL;
char *cmd_end;
char ch;
uint32_t rlen = 0; /* running length in parsing fsa */
uint32_t rnarg = 0; /* running # arg used by parsing fsa */
enum {
SW_START,
SW_NARG,
SW_NARG_LF,
SW_REQ_TYPE_LEN,
SW_REQ_TYPE_LEN_LF,
SW_REQ_TYPE,
SW_REQ_TYPE_LF,
SW_KEY_LEN,
SW_KEY_LEN_LF,
SW_KEY,
SW_KEY_LF,
SW_ARG1_LEN,
SW_ARG1_LEN_LF,
SW_ARG1,
SW_ARG1_LF,
SW_ARG2_LEN,
SW_ARG2_LEN_LF,
SW_ARG2,
SW_ARG2_LF,
SW_ARG3_LEN,
SW_ARG3_LEN_LF,
SW_ARG3,
SW_ARG3_LF,
SW_ARGN_LEN,
SW_ARGN_LEN_LF,
SW_ARGN,
SW_ARGN_LF,
SW_SENTINEL
} state;
state = SW_START;
cmd_end = r->cmd + r->clen;
ASSERT(state >= SW_START && state < SW_SENTINEL);
ASSERT(r->cmd != NULL && r->clen > 0);
for (p = r->cmd; p < cmd_end; p++) {
ch = *p;
switch (state) {
case SW_START:
case SW_NARG:
if (token == NULL) {
if (ch != '*') {
goto error;
}
token = p;
/* req_start <- p */
r->narg_start = p;
rnarg = 0;
state = SW_NARG;
} else if (isdigit(ch)) {
rnarg = rnarg * 10 + (uint32_t)(ch - '0');
} else if (ch == CR) {
if (rnarg == 0) {
goto error;
}
r->narg = rnarg;
r->narg_end = p;
token = NULL;
state = SW_NARG_LF;
} else {
goto error;
}
break;
case SW_NARG_LF:
switch (ch) {
case LF:
state = SW_REQ_TYPE_LEN;
break;
default:
goto error;
}
break;
case SW_REQ_TYPE_LEN:
if (token == NULL) {
if (ch != '$') {
goto error;
}
token = p;
rlen = 0;
} else if (isdigit(ch)) {
rlen = rlen * 10 + (uint32_t)(ch - '0');
} else if (ch == CR) {
if (rlen == 0 || rnarg == 0) {
goto error;
}
rnarg--;
token = NULL;
state = SW_REQ_TYPE_LEN_LF;
} else {
goto error;
}
break;
case SW_REQ_TYPE_LEN_LF:
switch (ch) {
case LF:
state = SW_REQ_TYPE;
break;
default:
goto error;
}
break;
case SW_REQ_TYPE:
if (token == NULL) {
token = p;
}
m = token + rlen;
if (m >= cmd_end) {
//m = cmd_end - 1;
//p = m;
//break;
goto error;
}
if (*m != CR) {
goto error;
}
p = m; /* move forward by rlen bytes */
rlen = 0;
m = token;
token = NULL;
r->type = CMD_UNKNOWN;
switch (p - m) {
case 3:
if (str3icmp(m, 'g', 'e', 't')) {
r->type = CMD_REQ_REDIS_GET;
break;
}
if (str3icmp(m, 's', 'e', 't')) {
r->type = CMD_REQ_REDIS_SET;
break;
}
if (str3icmp(m, 't', 't', 'l')) {
r->type = CMD_REQ_REDIS_TTL;
break;
}
if (str3icmp(m, 'd', 'e', 'l')) {
r->type = CMD_REQ_REDIS_DEL;
break;
}
break;
case 4:
if (str4icmp(m, 'p', 't', 't', 'l')) {
r->type = CMD_REQ_REDIS_PTTL;
break;
}
if (str4icmp(m, 'd', 'e', 'c', 'r')) {
r->type = CMD_REQ_REDIS_DECR;
break;
}
if (str4icmp(m, 'd', 'u', 'm', 'p')) {
r->type = CMD_REQ_REDIS_DUMP;
break;
}
if (str4icmp(m, 'h', 'd', 'e', 'l')) {
r->type = CMD_REQ_REDIS_HDEL;
break;
}
if (str4icmp(m, 'h', 'g', 'e', 't')) {
r->type = CMD_REQ_REDIS_HGET;
break;
}
if (str4icmp(m, 'h', 'l', 'e', 'n')) {
r->type = CMD_REQ_REDIS_HLEN;
break;
}
if (str4icmp(m, 'h', 's', 'e', 't')) {
r->type = CMD_REQ_REDIS_HSET;
break;
}
if (str4icmp(m, 'i', 'n', 'c', 'r')) {
r->type = CMD_REQ_REDIS_INCR;
break;
}
if (str4icmp(m, 'l', 'l', 'e', 'n')) {
r->type = CMD_REQ_REDIS_LLEN;
break;
}
if (str4icmp(m, 'l', 'p', 'o', 'p')) {
r->type = CMD_REQ_REDIS_LPOP;
break;
}
if (str4icmp(m, 'l', 'r', 'e', 'm')) {
r->type = CMD_REQ_REDIS_LREM;
break;
}
if (str4icmp(m, 'l', 's', 'e', 't')) {
r->type = CMD_REQ_REDIS_LSET;
break;
}
if (str4icmp(m, 'r', 'p', 'o', 'p')) {
r->type = CMD_REQ_REDIS_RPOP;
break;
}
if (str4icmp(m, 's', 'a', 'd', 'd')) {
r->type = CMD_REQ_REDIS_SADD;
break;
}
if (str4icmp(m, 's', 'p', 'o', 'p')) {
r->type = CMD_REQ_REDIS_SPOP;
break;
}
if (str4icmp(m, 's', 'r', 'e', 'm')) {
r->type = CMD_REQ_REDIS_SREM;
break;
}
if (str4icmp(m, 't', 'y', 'p', 'e')) {
r->type = CMD_REQ_REDIS_TYPE;
break;
}
if (str4icmp(m, 'm', 'g', 'e', 't')) {
r->type = CMD_REQ_REDIS_MGET;
break;
}
if (str4icmp(m, 'm', 's', 'e', 't')) {
r->type = CMD_REQ_REDIS_MSET;
break;
}
if (str4icmp(m, 'z', 'a', 'd', 'd')) {
r->type = CMD_REQ_REDIS_ZADD;
break;
}
if (str4icmp(m, 'z', 'r', 'e', 'm')) {
r->type = CMD_REQ_REDIS_ZREM;
break;
}
if (str4icmp(m, 'e', 'v', 'a', 'l')) {
r->type = CMD_REQ_REDIS_EVAL;
break;
}
if (str4icmp(m, 's', 'o', 'r', 't')) {
r->type = CMD_REQ_REDIS_SORT;
break;
}
if (str4icmp(m, 'p', 'i', 'n', 'g')) {
r->type = CMD_REQ_REDIS_PING;
r->noforward = 1;
break;
}
if (str4icmp(m, 'q', 'u', 'i', 't')) {
r->type = CMD_REQ_REDIS_QUIT;
r->quit = 1;
break;
}
if (str4icmp(m, 'a', 'u', 't', 'h')) {
r->type = CMD_REQ_REDIS_AUTH;
r->noforward = 1;
break;
}
break;
case 5:
if (str5icmp(m, 'h', 'k', 'e', 'y', 's')) {
r->type = CMD_REQ_REDIS_HKEYS;
break;
}
if (str5icmp(m, 'h', 'm', 'g', 'e', 't')) {
r->type = CMD_REQ_REDIS_HMGET;
break;
}
if (str5icmp(m, 'h', 'm', 's', 'e', 't')) {
r->type = CMD_REQ_REDIS_HMSET;
break;
}
if (str5icmp(m, 'h', 'v', 'a', 'l', 's')) {
r->type = CMD_REQ_REDIS_HVALS;
break;
}
if (str5icmp(m, 'h', 's', 'c', 'a', 'n')) {
r->type = CMD_REQ_REDIS_HSCAN;
break;
}
if (str5icmp(m, 'l', 'p', 'u', 's', 'h')) {
r->type = CMD_REQ_REDIS_LPUSH;
break;
}
if (str5icmp(m, 'l', 't', 'r', 'i', 'm')) {
r->type = CMD_REQ_REDIS_LTRIM;
break;
}
if (str5icmp(m, 'r', 'p', 'u', 's', 'h')) {
r->type = CMD_REQ_REDIS_RPUSH;
break;
}
if (str5icmp(m, 's', 'c', 'a', 'r', 'd')) {
r->type = CMD_REQ_REDIS_SCARD;
break;
}
if (str5icmp(m, 's', 'd', 'i', 'f', 'f')) {
r->type = CMD_REQ_REDIS_SDIFF;
break;
}
if (str5icmp(m, 's', 'e', 't', 'e', 'x')) {
r->type = CMD_REQ_REDIS_SETEX;
break;
}
if (str5icmp(m, 's', 'e', 't', 'n', 'x')) {
r->type = CMD_REQ_REDIS_SETNX;
break;
}
if (str5icmp(m, 's', 'm', 'o', 'v', 'e')) {
r->type = CMD_REQ_REDIS_SMOVE;
break;
}
if (str5icmp(m, 's', 's', 'c', 'a', 'n')) {
r->type = CMD_REQ_REDIS_SSCAN;
break;
}
if (str5icmp(m, 'z', 'c', 'a', 'r', 'd')) {
r->type = CMD_REQ_REDIS_ZCARD;
break;
}
if (str5icmp(m, 'z', 'r', 'a', 'n', 'k')) {
r->type = CMD_REQ_REDIS_ZRANK;
break;
}
if (str5icmp(m, 'z', 's', 'c', 'a', 'n')) {
r->type = CMD_REQ_REDIS_ZSCAN;
break;
}
if (str5icmp(m, 'p', 'f', 'a', 'd', 'd')) {
r->type = CMD_REQ_REDIS_PFADD;
break;
}
break;
case 6:
if (str6icmp(m, 'a', 'p', 'p', 'e', 'n', 'd')) {
r->type = CMD_REQ_REDIS_APPEND;
break;
}
if (str6icmp(m, 'd', 'e', 'c', 'r', 'b', 'y')) {
r->type = CMD_REQ_REDIS_DECRBY;
break;
}
if (str6icmp(m, 'e', 'x', 'i', 's', 't', 's')) {
r->type = CMD_REQ_REDIS_EXISTS;
break;
}
if (str6icmp(m, 'e', 'x', 'p', 'i', 'r', 'e')) {
r->type = CMD_REQ_REDIS_EXPIRE;
break;
}
if (str6icmp(m, 'g', 'e', 't', 'b', 'i', 't')) {
r->type = CMD_REQ_REDIS_GETBIT;
break;
}
if (str6icmp(m, 'g', 'e', 't', 's', 'e', 't')) {
r->type = CMD_REQ_REDIS_GETSET;
break;
}
if (str6icmp(m, 'p', 's', 'e', 't', 'e', 'x')) {
r->type = CMD_REQ_REDIS_PSETEX;
break;
}
if (str6icmp(m, 'h', 's', 'e', 't', 'n', 'x')) {
r->type = CMD_REQ_REDIS_HSETNX;
break;
}
if (str6icmp(m, 'i', 'n', 'c', 'r', 'b', 'y')) {
r->type = CMD_REQ_REDIS_INCRBY;
break;
}
if (str6icmp(m, 'l', 'i', 'n', 'd', 'e', 'x')) {
r->type = CMD_REQ_REDIS_LINDEX;
break;
}
if (str6icmp(m, 'l', 'p', 'u', 's', 'h', 'x')) {
r->type = CMD_REQ_REDIS_LPUSHX;
break;
}
if (str6icmp(m, 'l', 'r', 'a', 'n', 'g', 'e')) {
r->type = CMD_REQ_REDIS_LRANGE;
break;
}
if (str6icmp(m, 'r', 'p', 'u', 's', 'h', 'x')) {
r->type = CMD_REQ_REDIS_RPUSHX;
break;
}
if (str6icmp(m, 's', 'e', 't', 'b', 'i', 't')) {
r->type = CMD_REQ_REDIS_SETBIT;
break;
}
if (str6icmp(m, 's', 'i', 'n', 't', 'e', 'r')) {
r->type = CMD_REQ_REDIS_SINTER;
break;
}
if (str6icmp(m, 's', 't', 'r', 'l', 'e', 'n')) {
r->type = CMD_REQ_REDIS_STRLEN;
break;
}
if (str6icmp(m, 's', 'u', 'n', 'i', 'o', 'n')) {
r->type = CMD_REQ_REDIS_SUNION;
break;
}
if (str6icmp(m, 'z', 'c', 'o', 'u', 'n', 't')) {
r->type = CMD_REQ_REDIS_ZCOUNT;
break;
}
if (str6icmp(m, 'z', 'r', 'a', 'n', 'g', 'e')) {
r->type = CMD_REQ_REDIS_ZRANGE;
break;
}
if (str6icmp(m, 'z', 's', 'c', 'o', 'r', 'e')) {
r->type = CMD_REQ_REDIS_ZSCORE;
break;
}
break;
case 7:
if (str7icmp(m, 'p', 'e', 'r', 's', 'i', 's', 't')) {
r->type = CMD_REQ_REDIS_PERSIST;
break;
}
if (str7icmp(m, 'p', 'e', 'x', 'p', 'i', 'r', 'e')) {
r->type = CMD_REQ_REDIS_PEXPIRE;
break;
}
if (str7icmp(m, 'h', 'e', 'x', 'i', 's', 't', 's')) {
r->type = CMD_REQ_REDIS_HEXISTS;
break;
}
if (str7icmp(m, 'h', 'g', 'e', 't', 'a', 'l', 'l')) {
r->type = CMD_REQ_REDIS_HGETALL;
break;
}
if (str7icmp(m, 'h', 'i', 'n', 'c', 'r', 'b', 'y')) {
r->type = CMD_REQ_REDIS_HINCRBY;
break;
}
if (str7icmp(m, 'l', 'i', 'n', 's', 'e', 'r', 't')) {
r->type = CMD_REQ_REDIS_LINSERT;
break;
}
if (str7icmp(m, 'z', 'i', 'n', 'c', 'r', 'b', 'y')) {
r->type = CMD_REQ_REDIS_ZINCRBY;
break;
}
if (str7icmp(m, 'e', 'v', 'a', 'l', 's', 'h', 'a')) {
r->type = CMD_REQ_REDIS_EVALSHA;
break;
}
if (str7icmp(m, 'r', 'e', 's', 't', 'o', 'r', 'e')) {
r->type = CMD_REQ_REDIS_RESTORE;
break;
}
if (str7icmp(m, 'p', 'f', 'c', 'o', 'u', 'n', 't')) {
r->type = CMD_REQ_REDIS_PFCOUNT;
break;
}
if (str7icmp(m, 'p', 'f', 'm', 'e', 'r', 'g', 'e')) {
r->type = CMD_REQ_REDIS_PFMERGE;
break;
}
break;
case 8:
if (str8icmp(m, 'e', 'x', 'p', 'i', 'r', 'e', 'a', 't')) {
r->type = CMD_REQ_REDIS_EXPIREAT;
break;
}
if (str8icmp(m, 'b', 'i', 't', 'c', 'o', 'u', 'n', 't')) {
r->type = CMD_REQ_REDIS_BITCOUNT;
break;
}
if (str8icmp(m, 'g', 'e', 't', 'r', 'a', 'n', 'g', 'e')) {
r->type = CMD_REQ_REDIS_GETRANGE;
break;
}
if (str8icmp(m, 's', 'e', 't', 'r', 'a', 'n', 'g', 'e')) {
r->type = CMD_REQ_REDIS_SETRANGE;
break;
}
if (str8icmp(m, 's', 'm', 'e', 'm', 'b', 'e', 'r', 's')) {
r->type = CMD_REQ_REDIS_SMEMBERS;
break;
}
if (str8icmp(m, 'z', 'r', 'e', 'v', 'r', 'a', 'n', 'k')) {
r->type = CMD_REQ_REDIS_ZREVRANK;
break;
}
break;
case 9:
if (str9icmp(m, 'p', 'e', 'x', 'p', 'i', 'r', 'e', 'a', 't')) {
r->type = CMD_REQ_REDIS_PEXPIREAT;
break;
}
if (str9icmp(m, 'r', 'p', 'o', 'p', 'l', 'p', 'u', 's', 'h')) {
r->type = CMD_REQ_REDIS_RPOPLPUSH;
break;
}
if (str9icmp(m, 's', 'i', 's', 'm', 'e', 'm', 'b', 'e', 'r')) {
r->type = CMD_REQ_REDIS_SISMEMBER;
break;
}
if (str9icmp(m, 'z', 'r', 'e', 'v', 'r', 'a', 'n', 'g', 'e')) {
r->type = CMD_REQ_REDIS_ZREVRANGE;
break;
}
if (str9icmp(m, 'z', 'l', 'e', 'x', 'c', 'o', 'u', 'n', 't')) {
r->type = CMD_REQ_REDIS_ZLEXCOUNT;
break;
}
break;
case 10:
if (str10icmp(m, 's', 'd', 'i', 'f', 'f', 's', 't', 'o', 'r', 'e')) {
r->type = CMD_REQ_REDIS_SDIFFSTORE;
break;
}
case 11:
if (str11icmp(m, 'i', 'n', 'c', 'r', 'b', 'y', 'f', 'l', 'o', 'a', 't')) {
r->type = CMD_REQ_REDIS_INCRBYFLOAT;
break;
}
if (str11icmp(m, 's', 'i', 'n', 't', 'e', 'r', 's', 't', 'o', 'r', 'e')) {
r->type = CMD_REQ_REDIS_SINTERSTORE;
break;
}
if (str11icmp(m, 's', 'r', 'a', 'n', 'd', 'm', 'e', 'm', 'b', 'e', 'r')) {
r->type = CMD_REQ_REDIS_SRANDMEMBER;
break;
}
if (str11icmp(m, 's', 'u', 'n', 'i', 'o', 'n', 's', 't', 'o', 'r', 'e')) {
r->type = CMD_REQ_REDIS_SUNIONSTORE;
break;
}
if (str11icmp(m, 'z', 'i', 'n', 't', 'e', 'r', 's', 't', 'o', 'r', 'e')) {
r->type = CMD_REQ_REDIS_ZINTERSTORE;
break;
}
if (str11icmp(m, 'z', 'u', 'n', 'i', 'o', 'n', 's', 't', 'o', 'r', 'e')) {
r->type = CMD_REQ_REDIS_ZUNIONSTORE;
break;
}
if (str11icmp(m, 'z', 'r', 'a', 'n', 'g', 'e', 'b', 'y', 'l', 'e', 'x')) {
r->type = CMD_REQ_REDIS_ZRANGEBYLEX;
break;
}
break;
case 12:
if (str12icmp(m, 'h', 'i', 'n', 'c', 'r', 'b', 'y', 'f', 'l', 'o', 'a', 't')) {
r->type = CMD_REQ_REDIS_HINCRBYFLOAT;
break;
}
break;
case 13:
if (str13icmp(m, 'z', 'r', 'a', 'n', 'g', 'e', 'b', 'y', 's', 'c', 'o', 'r', 'e')) {
r->type = CMD_REQ_REDIS_ZRANGEBYSCORE;
break;
}
break;
case 14:
if (str14icmp(m, 'z', 'r', 'e', 'm', 'r', 'a', 'n', 'g', 'e', 'b', 'y', 'l', 'e', 'x')) {
r->type = CMD_REQ_REDIS_ZREMRANGEBYLEX;