forked from valkey-io/valkey-glide-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalkey_glide_z_common.h
More file actions
926 lines (832 loc) · 52.5 KB
/
Copy pathvalkey_glide_z_common.h
File metadata and controls
926 lines (832 loc) · 52.5 KB
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
/*
+----------------------------------------------------------------------+
| Valkey Glide Z-Commands Common Utilities Header |
+----------------------------------------------------------------------+
| Copyright (c) 2023-2025 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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#ifndef VALKEY_GLIDE_Z_COMMON_H
#define VALKEY_GLIDE_Z_COMMON_H
#include "common.h"
#include "include/glide_bindings.h"
/* ====================================================================
* STRUCTURE DEFINITIONS
* ==================================================================== */
/**
* Range command options structure
* Used for ZRANGE, ZREVRANGE, ZRANGEBYSCORE, etc.
*/
typedef struct {
int withscores; /* WITHSCORES option */
int byscore; /* BYSCORE option */
int bylex; /* BYLEX option */
int rev; /* REV option */
int has_limit; /* Whether LIMIT is specified */
long limit_offset; /* LIMIT offset value */
long limit_count; /* LIMIT count value */
} range_options_t;
/**
* ZADD command options structure
*/
typedef struct {
int xx; /* XX option - only update existing elements */
int nx; /* NX option - only add new elements */
int lt; /* LT option - only update if new score is less than current */
int gt; /* GT option - only update if new score is greater than current */
int ch; /* CH option - return number of changed elements */
int incr; /* INCR option - increment the score */
} zadd_options_t;
/**
* Store command options structure
* Used for ZUNIONSTORE, ZINTERSTORE, etc.
*/
typedef struct {
zval* weights; /* Weights array */
int has_weights; /* Whether weights are specified */
zval* aggregate; /* Aggregate option (SUM, MIN, MAX) */
int has_aggregate; /* Whether aggregate is specified */
int withscores; /* WITHSCORES option */
} store_options_t;
/**
* Generic Z-command arguments structure
*/
typedef struct {
/* Key arguments */
const char* key;
size_t key_len;
/* Member arguments */
const char* member;
size_t member_len;
/* Multiple members */
zval* members;
int member_count;
/* Range arguments */
const char* min;
size_t min_len;
const char* max;
size_t max_len;
/* Numeric range arguments */
long start;
long end;
/* Score/increment arguments */
double score;
double increment;
/* Options */
zval* z_start;
zval* z_end;
zval* options;
zval* weights;
/* Command-specific flags */
int withscores;
/* Result destinations */
long* long_result;
double* double_result;
zval* zval_result;
} z_command_args_t;
/* ====================================================================
* BATCH STATE MANAGEMENT
* ==================================================================== */
/**
* Z-command batch state for result processing
*/
typedef struct {
z_result_processor_t processor; /* Result processing function */
void* output_ptr; /* Output pointer for results */
enum RequestType cmd_type; /* Command type for reference */
char** allocated_strings; /* Strings to free after batch */
int allocated_count; /* Number of allocated strings */
int withscores; /* For array result processing */
} z_batch_state_t;
/* ====================================================================
* COMMON EXECUTION FRAMEWORK
* ==================================================================== */
/**
* Generic Z-command execution framework with integrated batch support
*/
int execute_z_generic_command(valkey_glide_object* valkey_glide,
enum RequestType cmd_type,
z_command_args_t* args,
void* result_ptr,
z_result_processor_t process_result,
zval* return_value);
/**
* Process Z-command batch results
*/
int process_z_batch_results(valkey_glide_object* valkey_glide,
CommandResult* batch_result,
zval* return_value);
/**
* Process integer result (for commands returning count)
*/
int process_z_int_result(CommandResponse* response, void* output, zval* return_value);
/**
* Process double result (for commands returning scores)
*/
int process_z_double_result(CommandResponse* response, void* output, zval* return_value);
/**
* Process array result (for commands returning arrays)
*/
int process_z_array_result(CommandResponse* response, void* output, zval* return_value);
int process_z_array_zrand_result(CommandResponse* response, void* output, zval* return_value);
int process_z_long_to_zval_result(CommandResponse* response, void* output, zval* return_value);
/**
* Process rank result with optional score
*/
int process_z_rank_result(CommandResponse* response, void* output, zval* return_value);
/**
* Process BZPOP result (for BZPOPMAX/BZPOPMIN commands)
*/
int process_z_bzpop_result(CommandResponse* response, void* output, zval* return_value);
/* ====================================================================
* ARGUMENT PREPARATION UTILITIES
* ==================================================================== */
/**
* Prepare basic Z-command arguments (just key)
*/
int prepare_z_key_args(z_command_args_t* args, uintptr_t** args_out, unsigned long** args_len_out);
/**
* Prepare member-based Z-command arguments (key + member)
*/
int prepare_z_member_args(z_command_args_t* args,
uintptr_t** args_out,
unsigned long** args_len_out);
/**
* Prepare range-based Z-command arguments (key + min + max)
*/
int prepare_z_range_args(z_command_args_t* args,
uintptr_t** args_out,
unsigned long** args_len_out);
/**
* Prepare multi-member Z-command arguments (key + multiple members)
*/
int prepare_z_members_args(z_command_args_t* args,
uintptr_t** args_out,
unsigned long** args_len_out,
char*** allocated_strings,
int* allocated_count);
/**
* Prepare complex range Z-command arguments with options
*/
int prepare_z_complex_range_args(z_command_args_t* args,
uintptr_t** args_out,
enum RequestType cmd_type,
unsigned long** args_len_out,
char*** allocated_strings,
int* allocated_count);
/**
* Prepare store command arguments (destination + numkeys + keys + weights + aggregate)
*/
int prepare_z_store_args(z_command_args_t* args,
uintptr_t** args_out,
unsigned long** args_len_out,
char*** allocated_strings,
int* allocated_count);
/**
* Prepare ZINTERCARD command arguments (numkeys + keys + optional LIMIT)
*/
int prepare_z_intercard_args(z_command_args_t* args,
uintptr_t** args_out,
unsigned long** args_len_out,
char*** allocated_strings,
int* allocated_count);
/**
* Prepare ZUNION command arguments (numkeys + keys + WEIGHTS + AGGREGATE + WITHSCORES)
*/
int prepare_z_union_args(z_command_args_t* args,
uintptr_t** args_out,
unsigned long** args_len_out,
char*** allocated_strings,
int* allocated_count);
/**
* Prepare ZPOP command arguments (key + optional count)
*/
int prepare_z_pop_args(z_command_args_t* args,
uintptr_t** args_out,
unsigned long** args_len_out,
char*** allocated_strings,
int* allocated_count);
/**
* Prepare ZRANGESTORE command arguments (dst + src + start + end + range options)
*/
int prepare_z_rangestore_args(z_command_args_t* args,
uintptr_t** args_out,
unsigned long** args_len_out,
char*** allocated_strings,
int* allocated_count);
/**
* Prepare ZADD command arguments (key + options + score-member pairs)
*/
int prepare_z_zadd_args(z_command_args_t* args,
uintptr_t** args_out,
unsigned long** args_len_out,
char*** allocated_strings,
int* allocated_count);
/**
* Prepare ZDIFF command arguments (numkeys + keys + optional WITHSCORES)
*/
int prepare_z_zdiff_args(z_command_args_t* args,
uintptr_t** args_out,
unsigned long** args_len_out,
char*** allocated_strings,
int* allocated_count);
/**
* Prepare ZRANDMEMBER command arguments (key + optional count + optional WITHSCORES)
*/
int prepare_z_randmember_args(z_command_args_t* args,
uintptr_t** args_out,
unsigned long** args_len_out,
char*** allocated_strings,
int* allocated_count);
/**
* Prepare BZPOP command arguments (keys + timeout)
*/
int prepare_z_bzpop_args(z_command_args_t* args,
uintptr_t** args_out,
unsigned long** args_len_out,
char*** allocated_strings,
int* allocated_count);
/* ====================================================================
* OPTIONS PARSING HELPERS
* ==================================================================== */
/**
* Parse range command options (withscores, byscore, bylex, rev, limit)
* Returns 1 on success, 0 on failure
*/
int parse_range_options(zval* options, range_options_t* opts);
/**
* Parse ZADD command options (XX, NX, LT, GT, CH, INCR)
* Returns 1 on success, 0 on failure
*/
int parse_zadd_options(zval* options, zadd_options_t* opts);
/**
* Parse store command options (weights, aggregate) for ZUNIONSTORE-style commands
* Returns 1 on success, 0 on failure
*/
int parse_store_options(zval* weights, zval* options, store_options_t* opts);
/* ====================================================================
* CONVERSION & UTILITY HELPERS
* ==================================================================== */
/**
* Create LIMIT arguments (offset, count)
* Returns number of arguments added (0 or 3)
*/
int create_limit_args(range_options_t* opts,
uintptr_t* args,
unsigned long* args_len,
int start_idx,
char** allocated_strings,
int* allocated_count);
/* ====================================================================
* RESPONSE PROCESSING HELPERS
* ==================================================================== */
/**
* Flatten withscores array from [[member, score]] to [member => score]
* Returns 1 on success, 0 on failure
*/
int flatten_withscores_array(zval* return_value);
int prepare_mpop_arguments(const void* glide_client,
int is_blocking,
double timeout,
zval* keys,
const char* from,
size_t from_len,
long count,
unsigned long* arg_count_ptr,
uintptr_t** args_ptr,
unsigned long** args_len_ptr,
char** numkeys_str_ptr,
char** timeout_str_ptr,
char** count_str_ptr);
/* ====================================================================
* Z COMMAND IMPLEMENTATION FUNCTIONS (THIN WRAPPERS)
* ==================================================================== */
/* Traditional function signatures (original) */
int execute_zrandmember_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zscore_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zmscore_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zrank_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zrevrank_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zincrby_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zcount_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zlexcount_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zrem_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zremrangebylex_command(zval* object,
int argc,
zval* return_value,
zend_class_entry* ce);
int execute_zremrangebyrank_command(zval* object,
int argc,
zval* return_value,
zend_class_entry* ce);
int execute_zrange_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zcard_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
/* ZADD command with options */
int execute_zadd_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
/* ZRANGE command family */
int execute_zrangestore_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zdiffstore_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zinterstore_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zmpop_command_internal(valkey_glide_object* valkey_glide,
zval* object,
const char* cmd,
double timeout,
zval* keys,
const char* from,
size_t from_len,
long count,
zval* return_value);
int execute_zintercard_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zunion_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zunionstore_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zpopmax_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zpopmin_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zscan_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zrangebyscore_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zrevrangebyscore_command(zval* object,
int argc,
zval* return_value,
zend_class_entry* ce);
int execute_zrangebylex_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zdiff_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zinter_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zremrangebyscore_command(zval* object,
int argc,
zval* return_value,
zend_class_entry* ce);
int execute_bzmpop_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_zmpop_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_bzpopmax_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int execute_bzpopmin_command(zval* object, int argc, zval* return_value, zend_class_entry* ce);
int buffer_command_for_batch(valkey_glide_object* valkey_glide,
enum RequestType cmd_type,
const uintptr_t* args,
const unsigned long* args_len,
uintptr_t arg_count,
void* result_ptr,
z_result_processor_t process_result);
/**
* Initialize array return value and check for allocation success
*/
#define INIT_RETURN_ARRAY(return_value) \
do { \
array_init(return_value); \
} while (0)
/**
* Clean up and return FALSE on failure
*/
#define CLEANUP_AND_RETURN_FALSE(return_value) \
do { \
if (return_value && Z_TYPE_P(return_value) == IS_ARRAY) { \
zval_dtor(return_value); \
} \
RETURN_FALSE; \
} while (0)
/* Ultra-simple macro for ZRANDMEMBER method implementation */
#define ZRANDMEMBER_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zRandMember) { \
if (execute_zrandmember_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
zval_dtor(return_value); \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZRANGE method implementation */
#define ZRANGE_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zRange) { \
if (execute_zrange_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
zval_dtor(return_value); \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZRANGESTORE method implementation */
#define ZRANGESTORE_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zrangestore) { \
if (execute_zrangestore_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZRANGEBYSCORE method implementation */
#define ZRANGEBYSCORE_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zRangeByScore) { \
if (execute_zrangebyscore_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
zval_dtor(return_value); \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZREVRANGEBYSCORE method implementation */
#define ZREVRANGEBYSCORE_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zRevRangeByScore) { \
if (execute_zrevrangebyscore_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
zval_dtor(return_value); \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZRANGEBYLEX method implementation */
#define ZRANGEBYLEX_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zRangeByLex) { \
if (execute_zrangebylex_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
zval_dtor(return_value); \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZREMRANGEBYLEX method implementation */
#define ZREMRANGEBYLEX_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zRemRangeByLex) { \
if (execute_zremrangebylex_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZREM method implementation */
#define ZREM_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zRem) { \
if (execute_zrem_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZREMRANGEBYSCORE method implementation */
#define ZREMRANGEBYSCORE_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zRemRangeByScore) { \
if (execute_zremrangebyscore_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZREVRANK method implementation */
#define ZREVRANK_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zRevRank) { \
if (execute_zrevrank_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZREMRANGEBYRANK method implementation */
#define ZREMRANGEBYRANK_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zRemRangeByRank) { \
if (execute_zremrangebyrank_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZCOUNT method implementation */
#define ZCOUNT_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zCount) { \
if (execute_zcount_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZCARD method implementation */
#define ZCARD_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zCard) { \
if (execute_zcard_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZSCORE method implementation */
#define ZSCORE_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zScore) { \
if (execute_zscore_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZMSCORE method implementation */
#define ZMSCORE_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zMscore) { \
if (execute_zmscore_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
zval_dtor(return_value); \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZRANK method implementation */
#define ZRANK_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zRank) { \
if (execute_zrank_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZINCRBY method implementation */
#define ZINCRBY_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zIncrBy) { \
if (execute_zincrby_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZINTER method implementation */
#define ZINTER_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zinter) { \
if (execute_zinter_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
zval_dtor(return_value); \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZINTERCARD method implementation */
#define ZINTERCARD_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zintercard) { \
if (execute_zintercard_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZUNION method implementation */
#define ZUNION_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zunion) { \
if (execute_zunion_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
zval_dtor(return_value); \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZDIFFSTORE method implementation */
#define ZDIFFSTORE_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zdiffstore) { \
if (execute_zdiffstore_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZINTERSTORE method implementation */
#define ZINTERSTORE_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zinterstore) { \
if (execute_zinterstore_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZUNIONSTORE method implementation */
#define ZUNIONSTORE_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zunionstore) { \
if (execute_zunionstore_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZPOPMAX method implementation */
#define ZPOPMAX_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zPopMax) { \
if (execute_zpopmax_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
zval_dtor(return_value); \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZPOPMIN method implementation */
#define ZPOPMIN_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zPopMin) { \
if (execute_zpopmin_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
zval_dtor(return_value); \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZSCAN method implementation */
#define ZSCAN_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zscan) { \
if (execute_zscan_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for BZMPOP method implementation */
#define BZMPOP_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, bzmpop) { \
if (execute_bzmpop_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZMPOP method implementation */
#define ZMPOP_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zmpop) { \
if (execute_zmpop_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZADD method implementation */
#define ZADD_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zAdd) { \
if (execute_zadd_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZLEXCOUNT method implementation */
#define ZLEXCOUNT_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zLexCount) { \
if (execute_zlexcount_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for ZDIFF method implementation */
#define ZDIFF_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, zdiff) { \
if (execute_zdiff_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
zval_dtor(return_value); \
RETURN_FALSE; \
}
/* Ultra-simple macro for BZPOPMAX method implementation */
#define BZPOPMAX_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, bzPopMax) { \
if (execute_bzpopmax_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
/* Ultra-simple macro for BZPOPMIN method implementation */
#define BZPOPMIN_METHOD_IMPL(class_name) \
PHP_METHOD(class_name, bzPopMin) { \
if (execute_bzpopmin_command(getThis(), \
ZEND_NUM_ARGS(), \
return_value, \
strcmp(#class_name, "ValkeyGlideCluster") == 0 \
? get_valkey_glide_cluster_ce() \
: get_valkey_glide_ce())) { \
return; \
} \
RETURN_FALSE; \
}
#endif /* VALKEY_GLIDE_Z_COMMON_H */