forked from phpredis/phpredis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redis.c
3944 lines (3364 loc) · 117 KB
/
redis.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
/* -*- Mode: C; tab-width: 4 -*- */
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Original author: Alfonso Jimenez <[email protected]> |
| Maintainer: Nicolas Favre-Felix <[email protected]> |
| Maintainer: Nasreddine Bouafif <[email protected]> |
| Maintainer: Michael Grunder <[email protected]> |
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "common.h"
#include "ext/standard/info.h"
#include "php_ini.h"
#include "php_redis.h"
#include "redis_commands.h"
#include "redis_array.h"
#include "redis_cluster.h"
#include <zend_exceptions.h>
#ifdef PHP_SESSION
#include "ext/session/php_session.h"
#endif
#include <ext/standard/php_smart_str.h>
#include <ext/standard/php_var.h>
#include <ext/standard/php_math.h>
#include "library.h"
#define R_SUB_CALLBACK_CLASS_TYPE 1
#define R_SUB_CALLBACK_FT_TYPE 2
#define R_SUB_CLOSURE_TYPE 3
int le_redis_sock;
extern int le_redis_array;
#ifdef PHP_SESSION
extern ps_module ps_mod_redis;
extern ps_module ps_mod_redis_cluster;
#endif
extern zend_class_entry *redis_array_ce;
extern zend_class_entry *redis_cluster_ce;
zend_class_entry *redis_ce;
zend_class_entry *redis_exception_ce;
extern zend_class_entry *redis_cluster_exception_ce;
zend_class_entry *spl_ce_RuntimeException = NULL;
extern zend_function_entry redis_array_functions[];
extern zend_function_entry redis_cluster_functions[];
PHP_INI_BEGIN()
/* redis arrays */
PHP_INI_ENTRY("redis.arrays.names", "", PHP_INI_ALL, NULL)
PHP_INI_ENTRY("redis.arrays.hosts", "", PHP_INI_ALL, NULL)
PHP_INI_ENTRY("redis.arrays.previous", "", PHP_INI_ALL, NULL)
PHP_INI_ENTRY("redis.arrays.functions", "", PHP_INI_ALL, NULL)
PHP_INI_ENTRY("redis.arrays.index", "", PHP_INI_ALL, NULL)
PHP_INI_ENTRY("redis.arrays.autorehash", "", PHP_INI_ALL, NULL)
/* redis cluster */
PHP_INI_ENTRY("redis.clusters.seeds", "", PHP_INI_ALL, NULL)
PHP_INI_ENTRY("redis.clusters.timeout", "", PHP_INI_ALL, NULL)
PHP_INI_ENTRY("redis.clusters.read_timeout", "", PHP_INI_ALL, NULL)
PHP_INI_END()
/**
* Argument info for the SCAN proper
*/
ZEND_BEGIN_ARG_INFO_EX(arginfo_scan, 0, 0, 1)
ZEND_ARG_INFO(1, i_iterator)
ZEND_ARG_INFO(0, str_pattern)
ZEND_ARG_INFO(0, i_count)
ZEND_END_ARG_INFO();
/**
* Argument info for key scanning
*/
ZEND_BEGIN_ARG_INFO_EX(arginfo_kscan, 0, 0, 2)
ZEND_ARG_INFO(0, str_key)
ZEND_ARG_INFO(1, i_iterator)
ZEND_ARG_INFO(0, str_pattern)
ZEND_ARG_INFO(0, i_count)
ZEND_END_ARG_INFO();
#ifdef ZTS
ZEND_DECLARE_MODULE_GLOBALS(redis)
#endif
static zend_function_entry redis_functions[] = {
PHP_ME(Redis, __construct, NULL, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
PHP_ME(Redis, __destruct, NULL, ZEND_ACC_DTOR | ZEND_ACC_PUBLIC)
PHP_ME(Redis, connect, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, pconnect, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, close, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, ping, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, echo, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, get, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, set, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, setex, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, psetex, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, setnx, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, getSet, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, randomKey, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, renameKey, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, renameNx, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, getMultiple, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, exists, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, delete, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, incr, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, incrBy, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, incrByFloat, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, decr, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, decrBy, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, type, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, append, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, getRange, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, setRange, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, getBit, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, setBit, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, strlen, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, getKeys, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sort, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sortAsc, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sortAscAlpha, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sortDesc, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sortDescAlpha, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, lPush, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, rPush, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, lPushx, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, rPushx, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, lPop, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, rPop, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, blPop, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, brPop, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, lSize, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, lRemove, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, listTrim, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, lGet, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, lGetRange, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, lSet, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, lInsert, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sAdd, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sAddArray, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sSize, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sRemove, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sMove, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sPop, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sRandMember, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sContains, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sMembers, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sInter, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sInterStore, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sUnion, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sUnionStore, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sDiff, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sDiffStore, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, setTimeout, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, save, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, bgSave, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, lastSave, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, flushDB, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, flushAll, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, dbSize, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, auth, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, ttl, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, pttl, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, persist, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, info, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, select, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, move, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, bgrewriteaof, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, slaveof, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, object, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, bitop, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, bitcount, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, bitpos, NULL, ZEND_ACC_PUBLIC)
/* 1.1 */
PHP_ME(Redis, mset, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, msetnx, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, rpoplpush, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, brpoplpush, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zAdd, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zDelete, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zRange, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zRevRange, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zRangeByScore, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zRevRangeByScore, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zRangeByLex, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zRevRangeByLex, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zLexCount, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zRemRangeByLex, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zCount, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zDeleteRangeByScore, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zDeleteRangeByRank, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zCard, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zScore, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zRank, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zRevRank, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zInter, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zUnion, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zIncrBy, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, expireAt, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, pexpire, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, pexpireAt, NULL, ZEND_ACC_PUBLIC)
/* 1.2 */
PHP_ME(Redis, hGet, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, hSet, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, hSetNx, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, hDel, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, hLen, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, hKeys, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, hVals, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, hGetAll, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, hExists, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, hIncrBy, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, hIncrByFloat, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, hMset, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, hMget, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, multi, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, discard, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, exec, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, pipeline, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, watch, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, unwatch, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, publish, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, subscribe, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, psubscribe, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, unsubscribe, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, punsubscribe, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, time, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, role, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, eval, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, evalsha, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, script, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, debug, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, dump, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, restore, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, migrate, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, getLastError, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, clearLastError, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, _prefix, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, _serialize, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, _unserialize, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, client, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, command, NULL, ZEND_ACC_PUBLIC)
/* SCAN and friends */
PHP_ME(Redis, scan, arginfo_scan, ZEND_ACC_PUBLIC)
PHP_ME(Redis, hscan, arginfo_kscan, ZEND_ACC_PUBLIC)
PHP_ME(Redis, zscan, arginfo_kscan, ZEND_ACC_PUBLIC)
PHP_ME(Redis, sscan, arginfo_kscan, ZEND_ACC_PUBLIC)
/* HyperLogLog commands */
PHP_ME(Redis, pfadd, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, pfcount, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, pfmerge, NULL, ZEND_ACC_PUBLIC)
/* options */
PHP_ME(Redis, getOption, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, setOption, NULL, ZEND_ACC_PUBLIC)
/* config */
PHP_ME(Redis, config, NULL, ZEND_ACC_PUBLIC)
/* slowlog */
PHP_ME(Redis, slowlog, NULL, ZEND_ACC_PUBLIC)
/* Send a raw command and read raw results */
PHP_ME(Redis, rawcommand, NULL, ZEND_ACC_PUBLIC)
/* introspection */
PHP_ME(Redis, getHost, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, getPort, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, getDBNum, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, getTimeout, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, getReadTimeout, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, getPersistentID, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, getAuth, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, isConnected, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, getMode, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, wait, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Redis, pubsub, NULL, ZEND_ACC_PUBLIC)
/* aliases */
PHP_MALIAS(Redis, open, connect, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, popen, pconnect, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, lLen, lSize, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, sGetMembers, sMembers, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, mget, getMultiple, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, expire, setTimeout, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, zunionstore, zUnion, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, zinterstore, zInter, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, zRemove, zDelete, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, zRem, zDelete, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, zRemoveRangeByScore, zDeleteRangeByScore, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, zRemRangeByScore, zDeleteRangeByScore, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, zRemRangeByRank, zDeleteRangeByRank, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, zSize, zCard, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, substr, getRange, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, rename, renameKey, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, del, delete, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, keys, getKeys, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, lrem, lRemove, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, ltrim, listTrim, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, lindex, lGet, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, lrange, lGetRange, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, scard, sSize, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, srem, sRemove, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, sismember, sContains, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, zReverseRange, zRevRange, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, sendEcho, echo, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, evaluate, eval, NULL, ZEND_ACC_PUBLIC)
PHP_MALIAS(Redis, evaluateSha, evalsha, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
zend_module_entry redis_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
"redis",
NULL,
PHP_MINIT(redis),
PHP_MSHUTDOWN(redis),
PHP_RINIT(redis),
PHP_RSHUTDOWN(redis),
PHP_MINFO(redis),
#if ZEND_MODULE_API_NO >= 20010901
PHP_REDIS_VERSION,
#endif
STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_REDIS
ZEND_GET_MODULE(redis)
#endif
PHP_REDIS_API zend_class_entry *redis_get_exception_base(int root TSRMLS_DC)
{
#if HAVE_SPL
if (!root) {
if (!spl_ce_RuntimeException) {
zend_class_entry **pce;
if (zend_hash_find(CG(class_table), "runtimeexception",
sizeof("RuntimeException"),
(void**)&pce) == SUCCESS)
{
spl_ce_RuntimeException = *pce;
return *pce;
}
} else {
return spl_ce_RuntimeException;
}
}
#endif
#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 2)
return zend_exception_get_default();
#else
return zend_exception_get_default(TSRMLS_C);
#endif
}
/* Send a static DISCARD in case we're in MULTI mode. */
static int send_discard_static(RedisSock *redis_sock TSRMLS_DC) {
int result = FAILURE;
char *cmd, *resp;
int resp_len, cmd_len;
/* format our discard command */
cmd_len = redis_cmd_format_static(&cmd, "DISCARD", "");
/* send our DISCARD command */
if (redis_sock_write(redis_sock, cmd, cmd_len TSRMLS_CC) >= 0 &&
(resp = redis_sock_read(redis_sock,&resp_len TSRMLS_CC)) != NULL)
{
/* success if we get OK */
result = (resp_len == 3 && strncmp(resp,"+OK", 3)==0) ? SUCCESS:FAILURE;
/* free our response */
efree(resp);
}
/* free our command */
efree(cmd);
/* return success/failure */
return result;
}
/**
* redis_destructor_redis_sock
*/
static void redis_destructor_redis_sock(zend_rsrc_list_entry * rsrc TSRMLS_DC)
{
RedisSock *redis_sock = (RedisSock *) rsrc->ptr;
redis_sock_disconnect(redis_sock TSRMLS_CC);
redis_free_socket(redis_sock);
}
/**
* redis_sock_get
*/
PHP_REDIS_API int redis_sock_get(zval *id, RedisSock **redis_sock TSRMLS_DC,
int no_throw)
{
zval **socket;
int resource_type;
if (Z_TYPE_P(id) != IS_OBJECT || zend_hash_find(Z_OBJPROP_P(id), "socket",
sizeof("socket"), (void **) &socket) == FAILURE)
{
// Throw an exception unless we've been requested not to
if(!no_throw) {
zend_throw_exception(redis_exception_ce, "Redis server went away",
0 TSRMLS_CC);
}
return -1;
}
*redis_sock = (RedisSock *)zend_list_find(Z_LVAL_PP(socket),
&resource_type);
if (!*redis_sock || resource_type != le_redis_sock) {
// Throw an exception unless we've been requested not to
if(!no_throw) {
zend_throw_exception(redis_exception_ce, "Redis server went away",
0 TSRMLS_CC);
}
return -1;
}
if ((*redis_sock)->lazy_connect)
{
(*redis_sock)->lazy_connect = 0;
if (redis_sock_server_open(*redis_sock, 1 TSRMLS_CC) < 0) {
return -1;
}
}
return Z_LVAL_PP(socket);
}
/**
* redis_sock_get_direct
* Returns our attached RedisSock pointer if we're connected
*/
PHP_REDIS_API RedisSock *redis_sock_get_connected(INTERNAL_FUNCTION_PARAMETERS) {
zval *object;
RedisSock *redis_sock;
// If we can't grab our object, or get a socket, or we're not connected,
// return NULL
if((zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, redis_ce) == FAILURE) ||
(redis_sock_get(object, &redis_sock TSRMLS_CC, 1) < 0) ||
redis_sock->status != REDIS_SOCK_STATUS_CONNECTED)
{
return NULL;
}
/* Return our socket */
return redis_sock;
}
/* Redis and RedisCluster objects share serialization/prefixing settings so
* this is a generic function to add class constants to either */
static void add_class_constants(zend_class_entry *ce, int is_cluster TSRMLS_DC) {
zend_declare_class_constant_long(ce, ZEND_STRL("REDIS_NOT_FOUND"), REDIS_NOT_FOUND TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("REDIS_STRING"), REDIS_STRING TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("REDIS_SET"), REDIS_SET TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("REDIS_LIST"), REDIS_LIST TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("REDIS_ZSET"), REDIS_ZSET TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("REDIS_HASH"), REDIS_HASH TSRMLS_CC);
/* Cluster doesn't support pipelining at this time */
if(!is_cluster) {
zend_declare_class_constant_long(ce, ZEND_STRL("PIPELINE"), PIPELINE TSRMLS_CC);
}
/* Add common mode constants */
zend_declare_class_constant_long(ce, ZEND_STRL("ATOMIC"), ATOMIC TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("MULTI"), MULTI TSRMLS_CC);
/* options */
zend_declare_class_constant_long(ce, ZEND_STRL("OPT_SERIALIZER"), REDIS_OPT_SERIALIZER TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("OPT_PREFIX"), REDIS_OPT_PREFIX TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("OPT_READ_TIMEOUT"), REDIS_OPT_READ_TIMEOUT TSRMLS_CC);
/* serializer */
zend_declare_class_constant_long(ce, ZEND_STRL("SERIALIZER_NONE"), REDIS_SERIALIZER_NONE TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("SERIALIZER_PHP"), REDIS_SERIALIZER_PHP TSRMLS_CC);
/* scan options*/
zend_declare_class_constant_long(ce, ZEND_STRL("OPT_SCAN"), REDIS_OPT_SCAN TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("SCAN_RETRY"), REDIS_SCAN_RETRY TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("SCAN_NORETRY"), REDIS_SCAN_NORETRY TSRMLS_CC);
/* Cluster option to allow for slave failover */
if (is_cluster) {
zend_declare_class_constant_long(ce, ZEND_STRL("OPT_SLAVE_FAILOVER"), REDIS_OPT_FAILOVER TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("FAILOVER_NONE"), REDIS_FAILOVER_NONE TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("FAILOVER_ERROR"), REDIS_FAILOVER_ERROR TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("FAILOVER_DISTRIBUTE"), REDIS_FAILOVER_DISTRIBUTE TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("FAILOVER_DISTRIBUTE_SLAVES"), REDIS_FAILOVER_DISTRIBUTE_SLAVES TSRMLS_CC);
}
#ifdef HAVE_REDIS_IGBINARY
zend_declare_class_constant_long(ce, ZEND_STRL("SERIALIZER_IGBINARY"), REDIS_SERIALIZER_IGBINARY TSRMLS_CC);
#endif
zend_declare_class_constant_stringl(ce, "AFTER", 5, "after", 5 TSRMLS_CC);
zend_declare_class_constant_stringl(ce, "BEFORE", 6, "before", 6 TSRMLS_CC);
#ifdef PHP_SESSION
php_session_register_module(&ps_mod_redis);
php_session_register_module(&ps_mod_redis_cluster);
#endif
}
/**
* PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(redis)
{
struct timeval tv;
zend_class_entry redis_class_entry;
zend_class_entry redis_array_class_entry;
zend_class_entry redis_cluster_class_entry;
zend_class_entry redis_exception_class_entry;
zend_class_entry redis_cluster_exception_class_entry;
/* Seed random generator (for RedisCluster failover) */
gettimeofday(&tv, NULL);
srand(tv.tv_usec * tv.tv_sec);
REGISTER_INI_ENTRIES();
/* Redis class */
INIT_CLASS_ENTRY(redis_class_entry, "Redis", redis_functions);
redis_ce = zend_register_internal_class(&redis_class_entry TSRMLS_CC);
/* RedisArray class */
INIT_CLASS_ENTRY(redis_array_class_entry, "RedisArray",
redis_array_functions);
redis_array_ce = zend_register_internal_class(&redis_array_class_entry
TSRMLS_CC);
/* RedisCluster class */
INIT_CLASS_ENTRY(redis_cluster_class_entry, "RedisCluster",
redis_cluster_functions);
redis_cluster_ce = zend_register_internal_class(&redis_cluster_class_entry
TSRMLS_CC);
redis_cluster_ce->create_object = create_cluster_context;
le_redis_array = zend_register_list_destructors_ex(
redis_destructor_redis_array,
NULL,
"Redis Array", module_number
);
/* RedisException class */
INIT_CLASS_ENTRY(redis_exception_class_entry, "RedisException", NULL);
redis_exception_ce = zend_register_internal_class_ex(
&redis_exception_class_entry,
redis_get_exception_base(0 TSRMLS_CC),
NULL TSRMLS_CC
);
/* RedisClusterException class */
INIT_CLASS_ENTRY(redis_cluster_exception_class_entry,
"RedisClusterException", NULL);
redis_cluster_exception_ce = zend_register_internal_class_ex(
&redis_cluster_exception_class_entry,
rediscluster_get_exception_base(0 TSRMLS_CC),
NULL TSRMLS_CC
);
le_redis_sock = zend_register_list_destructors_ex(
redis_destructor_redis_sock,
NULL,
redis_sock_name, module_number
);
/* Add shared class constants to Redis and RedisCluster objects */
add_class_constants(redis_ce, 0 TSRMLS_CC);
add_class_constants(redis_cluster_ce, 1 TSRMLS_CC);
return SUCCESS;
}
/**
* PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION(redis)
{
return SUCCESS;
}
/**
* PHP_RINIT_FUNCTION
*/
PHP_RINIT_FUNCTION(redis)
{
return SUCCESS;
}
/**
* PHP_RSHUTDOWN_FUNCTION
*/
PHP_RSHUTDOWN_FUNCTION(redis)
{
return SUCCESS;
}
/**
* PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(redis)
{
php_info_print_table_start();
php_info_print_table_header(2, "Redis Support", "enabled");
php_info_print_table_row(2, "Redis Version", PHP_REDIS_VERSION);
php_info_print_table_end();
}
/* {{{ proto Redis Redis::__construct()
Public constructor */
PHP_METHOD(Redis, __construct)
{
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
RETURN_FALSE;
}
}
/* }}} */
/* {{{ proto Redis Redis::__destruct()
Public Destructor
*/
PHP_METHOD(Redis,__destruct) {
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
RETURN_FALSE;
}
// Grab our socket
RedisSock *redis_sock;
if (redis_sock_get(getThis(), &redis_sock TSRMLS_CC, 1) < 0) {
RETURN_FALSE;
}
// If we think we're in MULTI mode, send a discard
if(redis_sock->mode == MULTI) {
// Discard any multi commands, and free any callbacks that have been
// queued
send_discard_static(redis_sock TSRMLS_CC);
free_reply_callbacks(getThis(), redis_sock);
}
}
/* {{{ proto boolean Redis::connect(string host, int port [, double timeout [, long retry_interval]])
*/
PHP_METHOD(Redis, connect)
{
if (redis_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0) == FAILURE) {
RETURN_FALSE;
} else {
RETURN_TRUE;
}
}
/* }}} */
/* {{{ proto boolean Redis::pconnect(string host, int port [, double timeout])
*/
PHP_METHOD(Redis, pconnect)
{
if (redis_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1) == FAILURE) {
RETURN_FALSE;
} else {
/* reset multi/exec state if there is one. */
RedisSock *redis_sock;
if (redis_sock_get(getThis(), &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
RETURN_TRUE;
}
}
/* }}} */
PHP_REDIS_API int redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) {
zval *object;
zval **socket;
int host_len, id;
char *host = NULL;
long port = -1;
long retry_interval = 0;
char *persistent_id = NULL;
int persistent_id_len = -1;
double timeout = 0.0;
RedisSock *redis_sock = NULL;
#ifdef ZTS
/* not sure how in threaded mode this works so disabled persistence at
* first */
persistent = 0;
#endif
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
"Os|ldsl", &object, redis_ce, &host,
&host_len, &port, &timeout, &persistent_id,
&persistent_id_len, &retry_interval)
== FAILURE)
{
return FAILURE;
}
if (timeout < 0L || timeout > INT_MAX) {
zend_throw_exception(redis_exception_ce, "Invalid timeout",
0 TSRMLS_CC);
return FAILURE;
}
if (retry_interval < 0L || retry_interval > INT_MAX) {
zend_throw_exception(redis_exception_ce, "Invalid retry interval",
0 TSRMLS_CC);
return FAILURE;
}
/* If it's not a unix socket, set to default */
if(port == -1 && host_len && host[0] != '/') {
port = 6379;
}
/* if there is a redis sock already we have to remove it from the list */
if (redis_sock_get(object, &redis_sock TSRMLS_CC, 1) > 0) {
if (zend_hash_find(Z_OBJPROP_P(object), "socket",
sizeof("socket"), (void **) &socket) == FAILURE)
{
/* maybe there is a socket but the id isn't known.. what to do? */
} else {
/* The refcount should be decreased and destructor invoked */
zend_list_delete(Z_LVAL_PP(socket));
}
}
redis_sock = redis_sock_create(host, host_len, port, timeout, persistent,
persistent_id, retry_interval, 0);
if (redis_sock_server_open(redis_sock, 1 TSRMLS_CC) < 0) {
redis_free_socket(redis_sock);
return FAILURE;
}
#if PHP_VERSION_ID >= 50400
id = zend_list_insert(redis_sock, le_redis_sock TSRMLS_CC);
#else
id = zend_list_insert(redis_sock, le_redis_sock);
#endif
add_property_resource(object, "socket", id);
return SUCCESS;
}
/* {{{ proto long Redis::bitop(string op, string key, ...) */
PHP_METHOD(Redis, bitop)
{
REDIS_PROCESS_CMD(bitop, redis_long_response);
}
/* }}} */
/* {{{ proto long Redis::bitcount(string key, [int start], [int end])
*/
PHP_METHOD(Redis, bitcount)
{
REDIS_PROCESS_CMD(bitcount, redis_long_response);
}
/* }}} */
/* {{{ proto integer Redis::bitpos(string key, int bit, [int start, int end]) */
PHP_METHOD(Redis, bitpos)
{
REDIS_PROCESS_CMD(bitpos, redis_long_response);
}
/* }}} */
/* {{{ proto boolean Redis::close()
*/
PHP_METHOD(Redis, close)
{
zval *object;
RedisSock *redis_sock = NULL;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, redis_ce) == FAILURE) {
RETURN_FALSE;
}
if (redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
if (redis_sock_disconnect(redis_sock TSRMLS_CC)) {
RETURN_TRUE;
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto boolean Redis::set(string key, mixed val, long timeout,
* [array opt) */
PHP_METHOD(Redis, set) {
REDIS_PROCESS_CMD(set, redis_boolean_response);
}
/* {{{ proto boolean Redis::setex(string key, long expire, string value)
*/
PHP_METHOD(Redis, setex)
{
REDIS_PROCESS_KW_CMD("SETEX", redis_key_long_val_cmd, redis_boolean_response);
}
/* {{{ proto boolean Redis::psetex(string key, long expire, string value)
*/
PHP_METHOD(Redis, psetex)
{
REDIS_PROCESS_KW_CMD("PSETEX", redis_key_long_val_cmd,
redis_string_response);
}
/* {{{ proto boolean Redis::setnx(string key, string value)
*/
PHP_METHOD(Redis, setnx)
{
REDIS_PROCESS_KW_CMD("SETNX", redis_kv_cmd, redis_1_response);
}
/* }}} */
/* {{{ proto string Redis::getSet(string key, string value)
*/
PHP_METHOD(Redis, getSet)
{
REDIS_PROCESS_KW_CMD("GETSET", redis_kv_cmd, redis_string_response);
}
/* }}} */
/* {{{ proto string Redis::randomKey()
*/
PHP_METHOD(Redis, randomKey)
{
REDIS_PROCESS_KW_CMD("RANDOMKEY", redis_empty_cmd, redis_ping_response);
}
/* }}} */
/* {{{ proto string Redis::echo(string msg)
*/
PHP_METHOD(Redis, echo)
{
REDIS_PROCESS_KW_CMD("ECHO", redis_str_cmd, redis_string_response);
}
/* }}} */
/* {{{ proto string Redis::renameKey(string key_src, string key_dst)
*/
PHP_METHOD(Redis, renameKey)
{
REDIS_PROCESS_KW_CMD("RENAME", redis_key_key_cmd, redis_boolean_response);
}
/* }}} */
/* {{{ proto string Redis::renameNx(string key_src, string key_dst)
*/
PHP_METHOD(Redis, renameNx)
{
REDIS_PROCESS_KW_CMD("RENAMENX", redis_key_key_cmd, redis_1_response);
}
/* }}} */
/* }}} */
/* {{{ proto string Redis::get(string key)
*/
PHP_METHOD(Redis, get)
{
REDIS_PROCESS_KW_CMD("GET", redis_key_cmd, redis_string_response);
}
/* }}} */
/* {{{ proto string Redis::ping()
*/
PHP_METHOD(Redis, ping)
{
REDIS_PROCESS_KW_CMD("PING", redis_empty_cmd, redis_ping_response);
}
/* }}} */
/* {{{ proto boolean Redis::incr(string key [,int value])
*/
PHP_METHOD(Redis, incr){
REDIS_PROCESS_CMD(incr, redis_long_response);
}
/* }}} */
/* {{{ proto boolean Redis::incrBy(string key ,int value)
*/
PHP_METHOD(Redis, incrBy){
REDIS_PROCESS_KW_CMD("INCRBY", redis_key_long_cmd, redis_long_response);
}
/* }}} */
/* {{{ proto float Redis::incrByFloat(string key, float value)
*/
PHP_METHOD(Redis, incrByFloat) {
REDIS_PROCESS_KW_CMD("INCRBYFLOAT", redis_key_dbl_cmd,
redis_bulk_double_response);
}
/* }}} */
/* {{{ proto boolean Redis::decr(string key) */
PHP_METHOD(Redis, decr)
{
REDIS_PROCESS_CMD(decr, redis_long_response);
}
/* }}} */
/* {{{ proto boolean Redis::decrBy(string key ,int value)
*/
PHP_METHOD(Redis, decrBy){
REDIS_PROCESS_KW_CMD("DECRBY", redis_key_long_cmd, redis_long_response);
}
/* }}} */
/* {{{ proto array Redis::getMultiple(array keys)
*/
PHP_METHOD(Redis, getMultiple)
{
zval *object, *z_args, **z_ele;
HashTable *hash;
HashPosition ptr;
RedisSock *redis_sock;
smart_str cmd = {0};
int arg_count;
/* Make sure we have proper arguments */
if(zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa",
&object, redis_ce, &z_args) == FAILURE) {
RETURN_FALSE;
}
/* We'll need the socket */
if(redis_sock_get(object, &redis_sock TSRMLS_CC, 0) < 0) {
RETURN_FALSE;
}
/* Grab our array */
hash = Z_ARRVAL_P(z_args);
/* We don't need to do anything if there aren't any keys */
if((arg_count = zend_hash_num_elements(hash)) == 0) {
RETURN_FALSE;
}
/* Build our command header */
redis_cmd_init_sstr(&cmd, arg_count, "MGET", 4);
/* Iterate through and grab our keys */