common.h 19.6 KB
Newer Older
1
2
3
#include "php.h"
#include "php_ini.h"

4
5
6
#ifndef REDIS_COMMON_H
#define REDIS_COMMON_H

Michael Grunder's avatar
Michael Grunder committed
7
8
#define PHPREDIS_NOTUSED(v) ((void)v)

9
#include "zend_llist.h"
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
10
#include <ext/standard/php_var.h>
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
11
#include <ext/standard/php_math.h>
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
12
#include <zend_smart_str.h>
13
#include <ext/standard/php_smart_string.h>
14

15
#define PHPREDIS_ZVAL_IS_STRICT_FALSE(z) (Z_TYPE_P(z) == IS_FALSE)
16
#define PHPREDIS_GET_OBJECT(class_entry, z) (class_entry *)((char *)Z_OBJ_P(z) - XtOffsetOf(class_entry, std))
Michael Grunder's avatar
Michael Grunder committed
17

18
19
20
21
22
/* NULL check so Eclipse doesn't go crazy */
#ifndef NULL
#define NULL   ((void *) 0)
#endif

23
24
25
26
27
typedef enum {
    REDIS_SOCK_STATUS_FAILED = -1,
    REDIS_SOCK_STATUS_DISCONNECTED,
    REDIS_SOCK_STATUS_CONNECTED
} redis_sock_status;
28

29
30
#define _NL "\r\n"

31
32
/* properties */
#define REDIS_NOT_FOUND 0
Michael Grunder's avatar
Michael Grunder committed
33
34
35
36
37
#define REDIS_STRING    1
#define REDIS_SET       2
#define REDIS_LIST      3
#define REDIS_ZSET      4
#define REDIS_HASH      5
38
#define REDIS_STREAM    6
39

40
41
#ifdef PHP_WIN32
#define PHP_REDIS_API __declspec(dllexport)
Michael Grunder's avatar
Michael Grunder committed
42
#define phpredis_atoi64(p) _atoi64((p))
43
44
#else
#define PHP_REDIS_API
Michael Grunder's avatar
Michael Grunder committed
45
#define phpredis_atoi64(p) atoll((p))
46
47
#endif

48
49
/* reply types */
typedef enum _REDIS_REPLY_TYPE {
50
    TYPE_EOF       = -1,
Michael Grunder's avatar
Michael Grunder committed
51
    TYPE_LINE      = '+',
Michael Grunder's avatar
Michael Grunder committed
52
53
54
55
    TYPE_INT       = ':',
    TYPE_ERR       = '-',
    TYPE_BULK      = '$',
    TYPE_MULTIBULK = '*'
56
57
} REDIS_REPLY_TYPE;

Michael Grunder's avatar
Michael Grunder committed
58
59
60
61
62
63
64
65
/* SCAN variants */
typedef enum _REDIS_SCAN_TYPE {
    TYPE_SCAN,
    TYPE_SSCAN,
    TYPE_HSCAN,
    TYPE_ZSCAN
} REDIS_SCAN_TYPE;

Michael Grunder's avatar
Michael Grunder committed
66
67
68
69
70
71
72
/* PUBSUB subcommands */
typedef enum _PUBSUB_TYPE {
    PUBSUB_CHANNELS,
    PUBSUB_NUMSUB,
    PUBSUB_NUMPAT
} PUBSUB_TYPE;

73
/* options */
Michael Grunder's avatar
Michael Grunder committed
74
75
76
77
#define REDIS_OPT_SERIALIZER         1
#define REDIS_OPT_PREFIX             2
#define REDIS_OPT_READ_TIMEOUT       3
#define REDIS_OPT_SCAN               4
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
78
#define REDIS_OPT_FAILOVER           5
79
80
#define REDIS_OPT_TCP_KEEPALIVE      6
#define REDIS_OPT_COMPRESSION        7
81
#define REDIS_OPT_REPLY_LITERAL      8
Remi Collet's avatar
Remi Collet committed
82
#define REDIS_OPT_COMPRESSION_LEVEL  9
83

84
/* cluster options */
85
86
87
88
#define REDIS_FAILOVER_NONE              0
#define REDIS_FAILOVER_ERROR             1
#define REDIS_FAILOVER_DISTRIBUTE        2
#define REDIS_FAILOVER_DISTRIBUTE_SLAVES 3
89
/* serializers */
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
90
91
92
93
94
95
96
typedef enum {
    REDIS_SERIALIZER_NONE,
    REDIS_SERIALIZER_PHP,
    REDIS_SERIALIZER_IGBINARY,
    REDIS_SERIALIZER_MSGPACK,
    REDIS_SERIALIZER_JSON
} redis_serializer;
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
97
98
99
/* compression */
#define REDIS_COMPRESSION_NONE 0
#define REDIS_COMPRESSION_LZF  1
Remi Collet's avatar
Remi Collet committed
100
#define REDIS_COMPRESSION_ZSTD 2
101

Michael Grunder's avatar
Michael Grunder committed
102
103
104
105
/* SCAN options */
#define REDIS_SCAN_NORETRY 0
#define REDIS_SCAN_RETRY 1

106
107
/* GETBIT/SETBIT offset range limits */
#define BITOP_MIN_OFFSET 0
108
#define BITOP_MAX_OFFSET 4294967295U
109

110
111
112
113
114
/* Transaction modes */
#define ATOMIC   0
#define MULTI    1
#define PIPELINE 2

Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
115
116
117
#define IS_ATOMIC(redis_sock) (redis_sock->mode == ATOMIC)
#define IS_MULTI(redis_sock) (redis_sock->mode & MULTI)
#define IS_PIPELINE(redis_sock) (redis_sock->mode & PIPELINE)
118

Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
119
#define PIPELINE_ENQUEUE_COMMAND(cmd, cmd_len) do { \
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
120
    if (redis_sock->pipeline_cmd == NULL) { \
121
        redis_sock->pipeline_cmd = zend_string_init(cmd, cmd_len, 0); \
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
122
    } else { \
123
124
125
        size_t pipeline_len = ZSTR_LEN(redis_sock->pipeline_cmd); \
        redis_sock->pipeline_cmd = zend_string_realloc(redis_sock->pipeline_cmd, pipeline_len + cmd_len, 0); \
        memcpy(&ZSTR_VAL(redis_sock->pipeline_cmd)[pipeline_len], cmd, cmd_len); \
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
126
127
    } \
} while (0)
Michael Grunder's avatar
Michael Grunder committed
128
129

#define SOCKET_WRITE_COMMAND(redis_sock, cmd, cmd_len) \
Remi Collet's avatar
Remi Collet committed
130
    if(redis_sock_write(redis_sock, cmd, cmd_len) < 0) { \
Michael Grunder's avatar
Michael Grunder committed
131
    efree(cmd); \
132
    RETURN_FALSE; \
Nicolas Favre-Felix's avatar
Nicolas Favre-Felix committed
133
}
134

Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
135
#define REDIS_SAVE_CALLBACK(callback, closure_context) do { \
136
137
138
139
    fold_item *fi = malloc(sizeof(fold_item)); \
    fi->fun = (void *)callback; \
    fi->ctx = closure_context; \
    fi->next = NULL; \
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
140
    if (redis_sock->current) { \
141
        redis_sock->current->next = fi; \
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
142
    } \
143
    redis_sock->current = fi; \
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
144
145
146
147
    if (NULL == redis_sock->head) { \
        redis_sock->head = redis_sock->current; \
    } \
} while (0)
148

Michael Grunder's avatar
Michael Grunder committed
149
#define REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len) \
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
150
    if (IS_PIPELINE(redis_sock)) { \
Michael Grunder's avatar
Michael Grunder committed
151
        PIPELINE_ENQUEUE_COMMAND(cmd, cmd_len); \
152
153
154
155
    } else { \
        SOCKET_WRITE_COMMAND(redis_sock, cmd, cmd_len); \
    } \
    efree(cmd);
156

157
#define REDIS_PROCESS_RESPONSE_CLOSURE(function, closure_context) \
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
158
    if (!IS_PIPELINE(redis_sock)) { \
Remi Collet's avatar
Remi Collet committed
159
        if (redis_response_enqueued(redis_sock) != SUCCESS) { \
160
161
162
163
164
            RETURN_FALSE; \
        } \
    } \
    REDIS_SAVE_CALLBACK(function, closure_context); \
    RETURN_ZVAL(getThis(), 1, 0); \
165

166
167
168
#define REDIS_PROCESS_RESPONSE(function) else { \
    REDIS_PROCESS_RESPONSE_CLOSURE(function, NULL) \
}
169

170
171
172
173
174
/* Clear redirection info */
#define REDIS_MOVED_CLEAR(redis_sock) \
    redis_sock->redir_slot = 0; \
    redis_sock->redir_port = 0; \
    redis_sock->redir_type = MOVED_NONE; \
175
176
177
178

/* Process a command assuming our command where our command building
 * function is redis_<cmdname>_cmd */
#define REDIS_PROCESS_CMD(cmdname, resp_func) \
Michael Grunder's avatar
Michael Grunder committed
179
    RedisSock *redis_sock; char *cmd; int cmd_len; void *ctx=NULL; \
Remi Collet's avatar
Remi Collet committed
180
    if ((redis_sock = redis_sock_get(getThis(), 0)) == NULL || \
181
       redis_##cmdname##_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU,redis_sock, \
Michael Grunder's avatar
Michael Grunder committed
182
                             &cmd, &cmd_len, NULL, &ctx)==FAILURE) { \
183
184
185
            RETURN_FALSE; \
    } \
    REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len); \
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
186
    if (IS_ATOMIC(redis_sock)) { \
Michael Grunder's avatar
Michael Grunder committed
187
        resp_func(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, ctx); \
188
189
190
    } else { \
        REDIS_PROCESS_RESPONSE_CLOSURE(resp_func, ctx) \
    }
191
192
193

/* Process a command but with a specific command building function 
 * and keyword which is passed to us*/
194
#define REDIS_PROCESS_KW_CMD(kw, cmdfunc, resp_func) \
Michael Grunder's avatar
Michael Grunder committed
195
    RedisSock *redis_sock; char *cmd; int cmd_len; void *ctx=NULL; \
Remi Collet's avatar
Remi Collet committed
196
    if ((redis_sock = redis_sock_get(getThis(), 0)) == NULL || \
197
       cmdfunc(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, kw, &cmd, \
Michael Grunder's avatar
Michael Grunder committed
198
               &cmd_len, NULL, &ctx)==FAILURE) { \
199
200
201
            RETURN_FALSE; \
    } \
    REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len); \
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
202
    if (IS_ATOMIC(redis_sock)) { \
Michael Grunder's avatar
Michael Grunder committed
203
        resp_func(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, ctx); \
204
205
206
    } else { \
        REDIS_PROCESS_RESPONSE_CLOSURE(resp_func, ctx) \
    }
207

208
/* Extended SET argument detection */
209
210
211
212
213
214
215
216
#define IS_EX_ARG(a) \
    ((a[0]=='e' || a[0]=='E') && (a[1]=='x' || a[1]=='X') && a[2]=='\0')
#define IS_PX_ARG(a) \
    ((a[0]=='p' || a[0]=='P') && (a[1]=='x' || a[1]=='X') && a[2]=='\0')
#define IS_NX_ARG(a) \
    ((a[0]=='n' || a[0]=='N') && (a[1]=='x' || a[1]=='X') && a[2]=='\0')
#define IS_XX_ARG(a) \
    ((a[0]=='x' || a[0]=='X') && (a[1]=='x' || a[1]=='X') && a[2]=='\0')
217
218
219
220

#define IS_EX_PX_ARG(a) (IS_EX_ARG(a) || IS_PX_ARG(a))
#define IS_NX_XX_ARG(a) (IS_NX_ARG(a) || IS_XX_ARG(a))

Michael Grunder's avatar
Michael Grunder committed
221
222
223
224
225
226
/* Given a string and length, validate a zRangeByLex argument.  The semantics
 * here are that the argument must start with '(' or '[' or be just the char
 * '+' or '-' */
#define IS_LEX_ARG(s,l) \
    (l>0 && (*s=='(' || *s=='[' || (l==1 && (*s=='+' || *s=='-'))))

227
228
#define REDIS_ENABLE_MODE(redis_sock, m) (redis_sock->mode |= m)
#define REDIS_DISABLE_MODE(redis_sock, m) (redis_sock->mode &= ~m)
229

230
231
232
233
234
235
236
237
238
239
240
/* HOST_NAME_MAX doesn't exist everywhere */
#ifndef HOST_NAME_MAX
    #if defined(_POSIX_HOST_NAME_MAX)
        #define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
    #elif defined(MAXHOSTNAMELEN)
        #define HOST_NAME_MAX MAXHOSTNAMELEN
    #else
        #define HOST_NAME_MAX 255
    #endif
#endif

241
typedef struct fold_item {
Michael Grunder's avatar
Michael Grunder committed
242
243
244
    zval * (*fun)(INTERNAL_FUNCTION_PARAMETERS, void *, ...);
    void *ctx;
    struct fold_item *next;
245
} fold_item;
246

247
248
/* {{{ struct RedisSock */
typedef struct {
249
250
    php_stream        *stream;
    zend_string       *host;
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
251
    int               port;
252
253
254
255
256
257
258
259
    zend_string       *auth;
    double            timeout;
    double            read_timeout;
    long              retry_interval;
    redis_sock_status status;
    int               persistent;
    int               watching;
    zend_string       *persistent_id;
260

Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
261
    redis_serializer  serializer;
262
    int               compression;
Remi Collet's avatar
Remi Collet committed
263
    int               compression_level;
264
    long              dbNumber;
265

266
    zend_string       *prefix;
Nicolas Favre-Felix's avatar
Nicolas Favre-Felix committed
267

268
269
270
    short             mode;
    fold_item         *head;
    fold_item         *current;
271

272
    zend_string       *pipeline_cmd;
michael-grunder's avatar
michael-grunder committed
273

274
    zend_string       *err;
275

276
    int               scan;
277

278
    int               readonly;
279
    int               reply_literal;
280
    int               tcp_keepalive;
281
282
283
} RedisSock;
/* }}} */

284
285
286
287
288
typedef struct {
    zend_llist list;
    int nb_active;
} ConnectionPool;

Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
289
290
291
292
293
typedef struct {
    RedisSock *sock;
    zend_object std;
} redis_object;

294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
/** Argument info for any function expecting 0 args */
ZEND_BEGIN_ARG_INFO_EX(arginfo_void, 0, 0, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_key, 0, 0, 1)
    ZEND_ARG_INFO(0, key)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_value, 0, 0, 1)
    ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_key_value, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

311
312
313
314
315
316
ZEND_BEGIN_ARG_INFO_EX(arginfo_key_expire_value, 0, 0, 3)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, expire)
    ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

317
318
319
320
321
ZEND_BEGIN_ARG_INFO_EX(arginfo_key_newkey, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, newkey)
ZEND_END_ARG_INFO()

322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
ZEND_BEGIN_ARG_INFO_EX(arginfo_pairs, 0, 0, 1)
    ZEND_ARG_ARRAY_INFO(0, pairs, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_nkeys, 0, 0, 1)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_VARIADIC_INFO(0, other_keys)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_dst_nkeys, 0, 0, 2)
    ZEND_ARG_INFO(0, dst)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_VARIADIC_INFO(0, other_keys)
ZEND_END_ARG_INFO()

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
ZEND_BEGIN_ARG_INFO_EX(arginfo_key_min_max, 0, 0, 3)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, min)
    ZEND_ARG_INFO(0, max)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_key_member, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, member)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_key_member_value, 0, 0, 3)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, member)
    ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_key_members, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, member)
    ZEND_ARG_VARIADIC_INFO(0, other_members)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_key_timestamp, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, timestamp)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_key_offset, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, offset)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_key_offset_value, 0, 0, 3)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, offset)
    ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

Michael Grunder's avatar
Michael Grunder committed
376
377
378
379
380
ZEND_BEGIN_ARG_INFO_EX(arginfo_swapdb, 0, 0, 2)
    ZEND_ARG_INFO(0, srcdb)
    ZEND_ARG_INFO(0, dstdb)
ZEND_END_ARG_INFO()

381
382
383
384
385
386
ZEND_BEGIN_ARG_INFO_EX(arginfo_key_start_end, 0, 0, 3)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, start)
    ZEND_ARG_INFO(0, end)
ZEND_END_ARG_INFO()

387
388
389
390
ZEND_BEGIN_ARG_INFO_EX(arginfo_echo, 0, 0, 1)
    ZEND_ARG_INFO(0, msg)
ZEND_END_ARG_INFO()

391
392
393
394
395
ZEND_BEGIN_ARG_INFO_EX(arginfo_expire, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, timeout)
ZEND_END_ARG_INFO()

396
397
398
ZEND_BEGIN_ARG_INFO_EX(arginfo_set, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, value)
Pavlo Yatsukhnenko's avatar
Pavlo Yatsukhnenko committed
399
    ZEND_ARG_INFO(0, opts)
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
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_lset, 0, 0, 3)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, index)
    ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_blrpop, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, timeout_or_key)
    ZEND_ARG_VARIADIC_INFO(0, extra_args)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_linsert, 0, 0, 4)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, position)
    ZEND_ARG_INFO(0, pivot)
    ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_lindex, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_brpoplpush, 0, 0, 3)
    ZEND_ARG_INFO(0, src)
    ZEND_ARG_INFO(0, dst)
    ZEND_ARG_INFO(0, timeout)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_rpoplpush, 0, 0, 2)
    ZEND_ARG_INFO(0, src)
    ZEND_ARG_INFO(0, dst)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_sadd_array, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_ARRAY_INFO(0, options, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_srand_member, 0, 0, 1)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, count)
ZEND_END_ARG_INFO()

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
ZEND_BEGIN_ARG_INFO_EX(arginfo_zadd, 0, 0, 3)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, score)
    ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_zincrby, 0, 0, 3)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, value)
    ZEND_ARG_INFO(0, member)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_hmget, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_ARRAY_INFO(0, keys, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_hmset, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_ARRAY_INFO(0, pairs, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_bitop, 0, 0, 3)
    ZEND_ARG_INFO(0, operation)
    ZEND_ARG_INFO(0, ret_key)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_VARIADIC_INFO(0, other_keys)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_bitpos, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, bit)
    ZEND_ARG_INFO(0, start)
    ZEND_ARG_INFO(0, end)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_ltrim, 0, 0, 3)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, start)
    ZEND_ARG_INFO(0, stop)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_publish, 0, 0, 2)
    ZEND_ARG_INFO(0, channel)
    ZEND_ARG_INFO(0, message)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_pfadd, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_ARRAY_INFO(0, elements, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_pfmerge, 0, 0, 2)
    ZEND_ARG_INFO(0, dstkey)
    ZEND_ARG_ARRAY_INFO(0, keys, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_restore, 0, 0, 3)
    ZEND_ARG_INFO(0, ttl)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_smove, 0, 0, 3)
    ZEND_ARG_INFO(0, src)
    ZEND_ARG_INFO(0, dst)
    ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_zrange, 0, 0, 3)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, start)
    ZEND_ARG_INFO(0, end)
    ZEND_ARG_INFO(0, scores)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_zrangebyscore, 0, 0, 3)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, start)
    ZEND_ARG_INFO(0, end)
    ZEND_ARG_ARRAY_INFO(0, options, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_zrangebylex, 0, 0, 3)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, min)
    ZEND_ARG_INFO(0, max)
    ZEND_ARG_INFO(0, offset)
    ZEND_ARG_INFO(0, limit)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_zstore, 0, 0, 2)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_ARRAY_INFO(0, keys, 0)
    ZEND_ARG_ARRAY_INFO(0, weights, 1)
    ZEND_ARG_INFO(0, aggregate)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_sort, 0, 0, 1)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_ARRAY_INFO(0, options, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_object, 0, 0, 2)
    ZEND_ARG_INFO(0, field)
    ZEND_ARG_INFO(0, key)
ZEND_END_ARG_INFO()

555
ZEND_BEGIN_ARG_INFO_EX(arginfo_subscribe, 0, 0, 2)
556
    ZEND_ARG_ARRAY_INFO(0, channels, 0)
557
    ZEND_ARG_INFO(0, callback)
558
559
ZEND_END_ARG_INFO()

560
ZEND_BEGIN_ARG_INFO_EX(arginfo_psubscribe, 0, 0, 2)
561
    ZEND_ARG_ARRAY_INFO(0, patterns, 0)
562
    ZEND_ARG_INFO(0, callback)
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
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_unsubscribe, 0, 0, 1)
    ZEND_ARG_INFO(0, channel)
    ZEND_ARG_VARIADIC_INFO(0, other_channels)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_punsubscribe, 0, 0, 1)
    ZEND_ARG_INFO(0, pattern)
    ZEND_ARG_VARIADIC_INFO(0, other_patterns)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_eval, 0, 0, 1)
    ZEND_ARG_INFO(0, script)
    ZEND_ARG_INFO(0, args)
    ZEND_ARG_INFO(0, num_keys)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_evalsha, 0, 0, 1)
    ZEND_ARG_INFO(0, script_sha)
    ZEND_ARG_INFO(0, args)
    ZEND_ARG_INFO(0, num_keys)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_getoption, 0, 0, 1)
    ZEND_ARG_INFO(0, option)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_setoption, 0, 0, 2)
    ZEND_ARG_INFO(0, option)
    ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_watch, 0, 0, 1)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_VARIADIC_INFO(0, other_keys)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_command, 0, 0, 0)
    ZEND_ARG_VARIADIC_INFO(0, args)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_rawcommand, 0, 0, 1)
    ZEND_ARG_INFO(0, cmd)
    ZEND_ARG_VARIADIC_INFO(0, args)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_geoadd, 0, 0, 4)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, lng)
    ZEND_ARG_INFO(0, lat)
    ZEND_ARG_INFO(0, member)
    ZEND_ARG_VARIADIC_INFO(0, other_triples)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_geodist, 0, 0, 3)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, src)
    ZEND_ARG_INFO(0, dst)
    ZEND_ARG_INFO(0, unit)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_georadius, 0, 0, 5)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, lng)
    ZEND_ARG_INFO(0, lan)
    ZEND_ARG_INFO(0, radius)
    ZEND_ARG_INFO(0, unit)
    ZEND_ARG_ARRAY_INFO(0, opts, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_georadiusbymember, 0, 0, 4)
    ZEND_ARG_INFO(0, key)
    ZEND_ARG_INFO(0, member)
    ZEND_ARG_INFO(0, radius)
    ZEND_ARG_INFO(0, unit)
    ZEND_ARG_ARRAY_INFO(0, opts, 0)
ZEND_END_ARG_INFO()

Michael Grunder's avatar
Michael Grunder committed
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
ZEND_BEGIN_ARG_INFO_EX(arginfo_xadd, 0, 0, 3)
    ZEND_ARG_INFO(0, str_key)
    ZEND_ARG_INFO(0, str_id)
    ZEND_ARG_ARRAY_INFO(0, arr_fields, 0)
    ZEND_ARG_INFO(0, i_maxlen)
    ZEND_ARG_INFO(0, boo_approximate)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_xpending, 0, 0, 2)
    ZEND_ARG_INFO(0, str_key)
    ZEND_ARG_INFO(0, str_group)
    ZEND_ARG_INFO(0, str_start)
    ZEND_ARG_INFO(0, str_end)
    ZEND_ARG_INFO(0, i_count)
    ZEND_ARG_INFO(0, str_consumer)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_xrange, 0, 0, 3)
    ZEND_ARG_INFO(0, str_key)
    ZEND_ARG_INFO(0, str_start)
    ZEND_ARG_INFO(0, str_end)
    ZEND_ARG_INFO(0, i_count)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_xread, 0, 0, 1)
    ZEND_ARG_ARRAY_INFO(0, arr_streams, 0)
    ZEND_ARG_INFO(0, i_count)
    ZEND_ARG_INFO(0, i_block)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_xreadgroup, 0, 0, 3)
    ZEND_ARG_INFO(0, str_group)
    ZEND_ARG_INFO(0, str_consumer)
    ZEND_ARG_ARRAY_INFO(0, arr_streams, 0)
    ZEND_ARG_INFO(0, i_count)
    ZEND_ARG_INFO(0, i_block)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_xack, 0, 0, 3)
    ZEND_ARG_INFO(0, str_key)
    ZEND_ARG_INFO(0, str_group)
    ZEND_ARG_ARRAY_INFO(0, arr_ids, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_xclaim, 0, 0, 5)
    ZEND_ARG_INFO(0, str_key)
    ZEND_ARG_INFO(0, str_group)
    ZEND_ARG_INFO(0, str_consumer)
    ZEND_ARG_INFO(0, i_min_idle)
    ZEND_ARG_ARRAY_INFO(0, arr_ids, 0)
    ZEND_ARG_ARRAY_INFO(0, arr_opts, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_xgroup, 0, 0, 1)
    ZEND_ARG_INFO(0, str_operation)
    ZEND_ARG_INFO(0, str_key)
    ZEND_ARG_INFO(0, str_arg1)
    ZEND_ARG_INFO(0, str_arg2)
    ZEND_ARG_INFO(0, str_arg3)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_xinfo, 0, 0, 1)
    ZEND_ARG_INFO(0, str_cmd)
    ZEND_ARG_INFO(0, str_key)
    ZEND_ARG_INFO(0, str_group)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_xtrim, 0, 0, 2)
    ZEND_ARG_INFO(0, str_key)
    ZEND_ARG_INFO(0, i_maxlen)
    ZEND_ARG_INFO(0, boo_approximate)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_xdel, 0, 0, 2)
    ZEND_ARG_INFO(0, str_key)
    ZEND_ARG_ARRAY_INFO(0, arr_ids, 0)
ZEND_END_ARG_INFO()

720
#endif