-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathvalkey_glide_cluster.c
More file actions
1216 lines (952 loc) · 41.4 KB
/
valkey_glide_cluster.c
File metadata and controls
1216 lines (952 loc) · 41.4 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
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
/** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#if 1
#include <SAPI.h>
#include <php_variables.h>
#include <zend_exceptions.h>
#include <ext/spl/spl_exceptions.h>
#include "common.h"
#include "ext/standard/info.h"
#include "logger.h"
#include "valkey_glide_commands_common.h"
#include "valkey_glide_core_common.h"
#include "valkey_glide_geo_common.h"
#include "valkey_glide_hash_common.h" /* Include hash command framework */
#include "valkey_glide_list_common.h"
#include "valkey_glide_pubsub_common.h"
#include "valkey_glide_pubsub_introspection.h"
#include "valkey_glide_s_common.h"
#include "valkey_glide_x_common.h"
#include "valkey_glide_z_common.h"
#if PHP_VERSION_ID < 80000
#include "valkey_glide_cluster_legacy_arginfo.h"
#else
#include "valkey_glide_cluster_arginfo.h"
#include "zend_attributes.h"
#endif
/*
* PHP Methods
*/
/* Create a ValkeyGlideCluster Object */
static int valkey_glide_cluster_create_connection(
valkey_glide_object* valkey_glide,
valkey_glide_php_common_constructor_params_t common_params,
zend_long periodic_checks,
zend_bool periodic_checks_is_null) {
/* Validate database_id range early */
if (!common_params.database_id_is_null && common_params.database_id < 0) {
const char* error_message = "Database ID must be non-negative.";
VALKEY_LOG_ERROR("cluster_construct", error_message);
zend_throw_exception(get_valkey_glide_exception_ce(), error_message, 0);
return FAILURE;
}
/* Build cluster client configuration from individual parameters */
valkey_glide_cluster_client_configuration_t client_config;
memset(&client_config, 0, sizeof(client_config));
/* Set periodic checks */
client_config.periodic_checks_status =
periodic_checks_is_null ? VALKEY_GLIDE_PERIODIC_CHECKS_ENABLED_DEFAULT : periodic_checks;
client_config.periodic_checks_manual = NULL;
/* Populate configuration parameters shared between client and cluster connections. */
if (valkey_glide_build_client_config_base(&common_params, &client_config.base, true) ==
FAILURE) {
return FAILURE;
}
/* Parse cluster-specific advanced config options */
client_config.refresh_topology_from_initial_nodes = false; /* Default value */
if (common_params.advanced_config && Z_TYPE_P(common_params.advanced_config) == IS_ARRAY) {
HashTable* advanced_ht = Z_ARRVAL_P(common_params.advanced_config);
const char key_name[] = "refresh_topology_from_initial_nodes";
zval* refresh_topology_val =
zend_hash_str_find(advanced_ht, key_name, sizeof(key_name) - 1);
if (refresh_topology_val && Z_TYPE_P(refresh_topology_val) == IS_TRUE) {
client_config.refresh_topology_from_initial_nodes = true;
}
}
/* Issue the connection request. */
const ConnectionResponse* conn_resp = create_glide_cluster_client(&client_config);
if (conn_resp->connection_error_message) {
VALKEY_LOG_ERROR("cluster_construct", conn_resp->connection_error_message);
zend_throw_exception(
get_valkey_glide_exception_ce(), conn_resp->connection_error_message, 0);
free_connection_response((ConnectionResponse*) conn_resp);
valkey_glide_cleanup_client_config(&client_config.base);
return FAILURE;
} else {
VALKEY_LOG_INFO("cluster_construct", "ValkeyGlide cluster client created successfully");
valkey_glide->glide_client = conn_resp->conn_ptr;
}
free_connection_response((ConnectionResponse*) conn_resp);
/* Clean up temporary configuration structures */
valkey_glide_cleanup_client_config(&client_config.base);
return SUCCESS;
}
/**
* Maps PHPRedis-style constructor parameters to ValkeyGlide-style parameters.
* Modifies the provided parameters in place.
*/
static void map_phpredis_to_valkey_params(zval** addresses,
zval* seeds,
zend_long* request_timeout,
zend_bool* request_timeout_is_null,
double read_timeout,
zend_bool read_timeout_is_null,
zval** credentials,
zval* auth,
zend_long* read_from) {
/* Map seeds to addresses */
if (seeds != NULL) {
*addresses = seeds;
}
/* Map read_timeout to request_timeout (convert seconds to milliseconds) */
if (!read_timeout_is_null) {
*request_timeout = (zend_long) (read_timeout * 1000);
*request_timeout_is_null = 0;
}
/* Map auth to credentials */
if (auth != NULL) {
*credentials = auth;
}
/* Set default read_from for cluster if not specified */
if (*read_from == 0) {
*read_from = VALKEY_GLIDE_READ_FROM_PREFER_REPLICA;
}
}
PHP_METHOD(ValkeyGlideCluster, __construct) {
char* name = NULL;
size_t name_len = 0;
zval* seeds = NULL;
double timeout = 0.0;
zend_bool timeout_is_null = 1;
double read_timeout = 0.0;
zend_bool read_timeout_is_null = 1;
zend_bool persistent = 0;
zend_bool persistent_is_null = 1;
zval* auth = NULL;
zval* phpredis_context = NULL;
zval* addresses = NULL;
zend_bool use_tls = 0;
zend_bool use_tls_is_null = 1;
zval* credentials = NULL;
zend_long read_from = 0;
zend_bool read_from_is_null = 1;
zend_long request_timeout = 0;
zend_bool request_timeout_is_null = 1;
zval* reconnect_strategy = NULL;
char* client_name = NULL;
size_t client_name_len = 0;
zend_long periodic_checks = 0;
zend_bool periodic_checks_is_null = 1;
char* client_az = NULL;
size_t client_az_len = 0;
zval* advanced_config = NULL;
zend_bool lazy_connect = 0;
zend_bool lazy_connect_is_null = 1;
zend_long database_id = 0;
zend_bool database_id_is_null = 1;
zval* compression = NULL;
valkey_glide_php_common_constructor_params_t common_params;
valkey_glide_init_common_constructor_params(&common_params);
valkey_glide_object* valkey_glide;
ZEND_PARSE_PARAMETERS_START(0, 20)
Z_PARAM_OPTIONAL
Z_PARAM_STRING_OR_NULL(name, name_len)
Z_PARAM_ARRAY_OR_NULL(seeds)
Z_PARAM_DOUBLE_OR_NULL(timeout, timeout_is_null)
Z_PARAM_DOUBLE_OR_NULL(read_timeout, read_timeout_is_null)
Z_PARAM_BOOL_OR_NULL(persistent, persistent_is_null)
Z_PARAM_ZVAL_OR_NULL(auth)
Z_PARAM_ZVAL_OR_NULL(phpredis_context)
Z_PARAM_ARRAY_OR_NULL(addresses)
Z_PARAM_BOOL_OR_NULL(use_tls, use_tls_is_null)
Z_PARAM_ARRAY_OR_NULL(credentials)
Z_PARAM_LONG_OR_NULL(read_from, read_from_is_null)
Z_PARAM_LONG_OR_NULL(request_timeout, request_timeout_is_null)
Z_PARAM_ARRAY_OR_NULL(reconnect_strategy)
Z_PARAM_STRING_OR_NULL(client_name, client_name_len)
Z_PARAM_LONG_OR_NULL(periodic_checks, periodic_checks_is_null)
Z_PARAM_STRING_OR_NULL(client_az, client_az_len)
Z_PARAM_ARRAY_OR_NULL(advanced_config)
Z_PARAM_BOOL_OR_NULL(lazy_connect, lazy_connect_is_null)
Z_PARAM_LONG_OR_NULL(database_id, database_id_is_null)
Z_PARAM_ARRAY_OR_NULL(compression)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_THROWS());
valkey_glide = VALKEY_GLIDE_PHP_ZVAL_GET_OBJECT(valkey_glide_object, getThis());
/* Check if PHPRedis-style parameters are used */
zend_bool using_phpredis_style = (name != NULL || seeds != NULL || !timeout_is_null ||
!read_timeout_is_null || !persistent_is_null || auth != NULL);
/* Detect conflicting parameters */
if (using_phpredis_style && addresses != NULL) {
zend_throw_exception(get_valkey_glide_exception_ce(),
"Cannot specify both PHPRedis-style and ValkeyGlide-style parameters",
0);
return;
}
if (!timeout_is_null && !request_timeout_is_null) {
zend_throw_exception(get_valkey_glide_exception_ce(),
"Cannot specify both 'timeout' and 'request_timeout'",
0);
return;
}
/* Map PHPRedis parameters to ValkeyGlide parameters */
if (using_phpredis_style) {
map_phpredis_to_valkey_params(&addresses,
seeds,
&request_timeout,
&request_timeout_is_null,
read_timeout,
read_timeout_is_null,
&credentials,
auth,
&read_from);
}
/* Handle context (shared between PHPRedis and ValkeyGlide) */
if (phpredis_context != NULL) {
common_params.context = phpredis_context;
}
/* Populate common_params */
common_params.addresses = addresses;
common_params.use_tls = use_tls;
common_params.credentials = credentials;
common_params.read_from = read_from;
common_params.request_timeout = request_timeout;
common_params.request_timeout_is_null = request_timeout_is_null;
common_params.reconnect_strategy = reconnect_strategy;
common_params.client_name = client_name;
common_params.client_name_len = client_name_len;
common_params.client_az = client_az;
common_params.client_az_len = client_az_len;
common_params.advanced_config = advanced_config;
common_params.lazy_connect = lazy_connect;
common_params.lazy_connect_is_null = lazy_connect_is_null;
common_params.database_id = database_id;
common_params.database_id_is_null = database_id_is_null;
common_params.compression = compression;
/* Call helper function to create cluster connection */
valkey_glide_cluster_create_connection(
valkey_glide, common_params, periodic_checks, periodic_checks_is_null);
}
static zend_function_entry valkey_glide_cluster_methods[] = {
PHP_ME(ValkeyGlideCluster, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) PHP_FE_END};
/*
* ValkeyGlideCluster method implementation
*/
/* {{{ proto bool ValkeyGlideCluster::close() */
PHP_METHOD(ValkeyGlideCluster, close) {
valkey_glide_object* valkey_glide =
VALKEY_GLIDE_PHP_ZVAL_GET_OBJECT(valkey_glide_object, getThis());
if (valkey_glide->glide_client) {
close_glide_client(valkey_glide->glide_client);
valkey_glide->glide_client = NULL;
}
RETURN_TRUE;
}
/* {{{ proto array ValkeyGlideCluster::getStatistics() */
GET_STATISTICS_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto string ValkeyGlideCluster::get(string key) */
GET_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto string ValkeyGlideCluster::getdel(string key) */
GETDEL_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::set(string key, string value) */
SET_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* Generic handler for MGET/MSET/MSETNX */
/* {{{ proto array ValkeyGlideCluster::del(string key1, string key2, ... keyN) */
DEL_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto array ValkeyGlideCluster::unlink(string key1, string key2, ... keyN) */
UNLINK_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto array ValkeyGlideCluster::mget(array keys) */
MGET_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto bool ValkeyGlideCluster::mset(array keyvalues) */
MSET_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto array ValkeyGlideCluster::msetnx(array keyvalues) */
MSETNX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
GETEX_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto bool ValkeyGlideCluster::setex(string key, string value, int expiry) */
SETEX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::psetex(string key, string value, int expiry) */
PSETEX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::setnx(string key, string value) */
SETNX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto string ValkeyGlideCluster::getSet(string key, string value) */
GETSET_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto int ValkeyGlideCluster::exists(string $key, string ...$more_keys) */
EXISTS_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto int ValkeyGlideCluster::touch(string $key, string ...$more_keys) */
TOUCH_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto int ValkeyGlideCluster::type(string key) */
TYPE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto string ValkeyGlideCluster::pop(string key, [int count = 0]) */
LPOP_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
LPOS_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto string ValkeyGlideCluster::rpop(string key, [int count = 0]) */
RPOP_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::lset(string key, long index, string val) */
LSET_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto string ValkeyGlideCluster::spop(string key) */
SPOP_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto string|array ValkeyGlideCluster::srandmember(string key, [long count]) */
SRANDMEMBER_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto string ValkeyGlideCluster::strlen(string key) */
STRLEN_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto long ValkeyGlideCluster::lpush(string key, string val1, ... valN) */
LPUSH_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::rpush(string key, string val1, ... valN) */
RPUSH_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::blpop(string key1, ... keyN, long timeout) */
BLPOP_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto array ValkeyGlideCluster::brpop(string key1, ... keyN, long timeout */
BRPOP_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::rpushx(string key, mixed value) */
RPUSHX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::lpushx(string key, mixed value) */
LPUSHX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::linsert(string k,string pos,mix pvt,mix val) */
LINSERT_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto string ValkeyGlideCluster::lindex(string key, long index) */
LINDEX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::lrem(string key, long count, string val) */
LREM_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
LMOVE_METHOD_IMPL(ValkeyGlideCluster)
BLMOVE_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto long ValkeyGlideCluster::llen(string key) */
LLEN_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::scard(string key) */
SCARD_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::smembers(string key) */
SMEMBERS_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::sismember(string key) */
SISMEMBER_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::smismember(string key, string member0, ...memberN) */
SMISMEMBER_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::sadd(string key, string val1, ...) */
SADD_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::srem(string key, string val1 [, ...]) */
SREM_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::sunion(string key1, ... keyN) */
SUNION_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::sunionstore(string dst, string k1, ... kN) */
SUNIONSTORE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ ptoto array ValkeyGlideCluster::sinter(string k1, ... kN) */
SINTER_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto ValkeyGlideCluster::sintercard(array $keys, int $count = -1) */
SINTERCARD_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* }}} */
/* {{{ ptoto long ValkeyGlideCluster::sinterstore(string dst, string k1, ... kN) */
SINTERSTORE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::sdiff(string k1, ... kN) */
SDIFF_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::sdiffstore(string dst, string k1, ... kN) */
SDIFFSTORE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::smove(string src, string dst, string mem) */
SMOVE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::persist(string key) */
PERSIST_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::ttl(string key) */
TTL_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::pttl(string key) */
PTTL_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::zcard(string key) */
ZCARD_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto double ValkeyGlideCluster::zscore(string key) */
ZSCORE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
ZMSCORE_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto long ValkeyGlideCluster::zadd(string key,double score,string mem, ...) */
ZADD_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto double ValkeyGlideCluster::zincrby(string key, double by, string mem) */
ZINCRBY_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlideCluster::zremrangebyscore(string k, string s, string e) */
ZREMRANGEBYSCORE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlideCluster::zcount(string key, string s, string e) */
ZCOUNT_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::zrank(string key, mixed member) */
ZRANK_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::zrevrank(string key, mixed member) */
ZREVRANK_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::hlen(string key) */
HLEN_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::hkeys(string key) */
HKEYS_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::hvals(string key) */
HVALS_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::hSetEx(string key, long seconds, string field, string value,
* ...) */
HSETEX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::hPSetEx(string key, long milliseconds, string field, string
* value,
* ...) */
HPSETEX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::hExpire(string key, long time_value, string time_unit, string
* field, ...) */
HEXPIRE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::hExpireAt(string key, long timestamp, string field, ...) */
HEXPIREAT_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::hPExpire(string key, long milliseconds, string field, ...) */
HPEXPIRE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::hPExpireAt(string key, long timestamp_ms, string field, ...)
*/
HPEXPIREAT_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::hTtl(string key, string field, ...) */
HTTL_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::hPTtl(string key, string field, ...) */
HPTTL_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::hExpireTime(string key, string field, ...) */
HEXPIRETIME_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::hPExpireTime(string key, string field, ...) */
HPEXPIRETIME_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::hPersist(string key, string field, ...) */
HPERSIST_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto mixed ValkeyGlideCluster::hGetEx(string key, string field, long seconds, ...) */
HGETEX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto string ValkeyGlideCluster::hget(string key, string mem) */
HGET_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::hset(string key, string mem, string val) */
HSET_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::hsetnx(string key, string mem, string val) */
HSETNX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::hgetall(string key) */
HGETALL_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::hexists(string key, string member) */
HEXISTS_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::hincr(string key, string mem, long val) */
HINCRBY_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto double ValkeyGlideCluster::hincrbyfloat(string k, string m, double v) */
HINCRBYFLOAT_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::hmset(string key, array key_vals) */
HMSET_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::hrandfield(string key, [array $options]) */
HRANDFIELD_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::hdel(string key, string mem1, ... memN) */
HDEL_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::hmget(string key, array members) */
HMGET_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::hstrlen(string key, string field) */
HSTRLEN_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto string ValkeyGlideCluster::dump(string key) */
DUMP_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto long ValkeyGlideCluster::incr(string key) */
INCR_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::incrby(string key, long byval) */
INCRBY_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::decr(string key) */
DECR_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::decrby(string key, long byval) */
DECRBY_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto double ValkeyGlideCluster::incrbyfloat(string key, double val) */
INCRBYFLOAT_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::expire(string key, long sec) */
EXPIRE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::expireat(string key, long ts) */
EXPIREAT_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto bool ValkeyGlideCluster::pexpire(string key, long ms) */
PEXPIRE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::pexpireAt(string key, long milliseconds_timestamp [, string
* mode]) */
PEXPIREAT_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ ValkeyGlide::expiretime(string $key): int */
EXPIRETIME_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ ValkeyGlide::pexpiretime(string $key): int */
PEXPIRETIME_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto long ValkeyGlideCluster::append(string key, string val) */
APPEND_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::getbit(string key, long val) */
GETBIT_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::setbit(string key, long offset, bool onoff) */
SETBIT_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto long ValkeyGlideCluster::bitop(string op,string key,[string key2,...]) */
BITOP_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::bitcount(string key, [int start, int end]) */
BITCOUNT_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::bitpos(string key, int bit, [int s, int end]) */
BITPOS_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto string ValkeyGlideCluster::getrange(string key, long start, long end) */
GETRANGE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ prot ValkeyGlideCluster::lcs(string $key1, string $key2, ?array $options = NULL): mixed; */
LCS_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto ValkeyGlide|array|false ValkeyGlide::lmpop(array $keys, string $from, int $count = 1)
*/
LMPOP_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlide|array|false ValkeyGlide::blmpop(double $timeout, array $keys, string $from,
* int $count = 1) */
BLMPOP_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlide|array|false ValkeyGlide::zmpop(array $keys, string $from, int $count = 1)
*/
ZMPOP_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlide|array|false ValkeyGlide::bzmpop(double $timeout, array $keys, string $from,
* int $count = 1) */
BZMPOP_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto string ValkeyGlideCluster::ltrim(string key, long start, long end) */
LTRIM_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::lrange(string key, long start, long end) */
LRANGE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::zremrangebyrank(string k, long s, long e) */
ZREMRANGEBYRANK_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::rename(string key1, string key2) */
RENAME_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::renamenx(string key1, string key2) */
RENAMENX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::pfcount(string key) */
PFCOUNT_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::pfadd(string key, array vals) */
PFADD_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto bool ValkeyGlideCluster::pfmerge(string key, array keys) */
PFMERGE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto boolean ValkeyGlideCluster::restore(string key, long ttl, string val) */
RESTORE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::setrange(string key, long offset, string val) */
SETRANGE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto
* array ValkeyGlideCluster::zrange(string k, long s, long e, bool score = 0) */
ZRANGE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto
* array ValkeyGlideCluster::zrange(string $dstkey, string $srckey, long s, long e, array|bool
* $options = false) */
ZRANGESTORE_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto array
* ValkeyGlideCluster::zrangebyscore(string k, long s, long e, array opts) */
ZRANGEBYSCORE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlideCluster::zunionstore(string dst, array keys, [array weights,
* string agg]) */
ZUNIONSTORE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
ZDIFF_METHOD_IMPL(ValkeyGlideCluster)
ZDIFFSTORE_METHOD_IMPL(ValkeyGlideCluster)
ZINTER_METHOD_IMPL(ValkeyGlideCluster)
ZUNION_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto array ValkeyGlideCluster::zrandmember(string key, array options) */
ZRANDMEMBER_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlideCluster::zinterstore(string dst, array keys, [array weights,
* string agg]) */
ZINTERSTORE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlideCluster::zintercard(array $keys, int $count = -1) */
ZINTERCARD_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlideCluster::zrem(string key, string val1, ... valN) */
ZREM_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array
* ValkeyGlideCluster::zrevrangebyscore(string k, long s, long e, array opts) */
ZREVRANGEBYSCORE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::zrangebylex(string key, string min, string max,
* [offset, count]) */
ZRANGEBYLEX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::zlexcount(string key, string min, string max) */
ZLEXCOUNT_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto long ValkeyGlideCluster::zremrangebylex(string key, string min, string max) */
ZREMRANGEBYLEX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::zpopmax(string key) */
ZPOPMAX_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::zpopmin(string key) */
ZPOPMIN_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::bzPopMin(Array keys [, timeout]) }}} */
BZPOPMAX_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto array ValkeyGlideCluster::bzPopMax(Array keys [, timeout]) }}} */
BZPOPMIN_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto ValkeyGlideCluster::sort(string key, array options) */
SORT_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto ValkeyGlideCluster::sort_ro(string key, array options) */
SORT_RO_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto ValkeyGlideCluster::object(string subcmd, string key) */
OBJECT_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto null ValkeyGlideCluster::subscribe(array chans, callable cb) */
PHP_METHOD(ValkeyGlideCluster, subscribe) {
valkey_glide_object* valkey_glide =
VALKEY_GLIDE_PHP_ZVAL_GET_OBJECT(valkey_glide_object, getThis());
if (!valkey_glide->glide_client) {
zend_throw_exception(get_valkey_glide_exception_ce(), "Client not connected", 0);
RETURN_FALSE;
}
valkey_glide_subscribe_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, valkey_glide->glide_client);
}
/* }}} */
/* {{{ proto null ValkeyGlideCluster::psubscribe(array pats, callable cb) */
PHP_METHOD(ValkeyGlideCluster, psubscribe) {
valkey_glide_object* valkey_glide =
VALKEY_GLIDE_PHP_ZVAL_GET_OBJECT(valkey_glide_object, getThis());
if (!valkey_glide->glide_client) {
zend_throw_exception(get_valkey_glide_exception_ce(), "Client not connected", 0);
RETURN_FALSE;
}
valkey_glide_psubscribe_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, valkey_glide->glide_client);
}
/* }}} */
/* {{{ proto array ValkeyGlideCluster::unsubscribe(array chans) */
PHP_METHOD(ValkeyGlideCluster, unsubscribe) {
valkey_glide_object* valkey_glide =
VALKEY_GLIDE_PHP_ZVAL_GET_OBJECT(valkey_glide_object, getThis());
if (!valkey_glide->glide_client) {
zend_throw_exception(get_valkey_glide_exception_ce(), "Client not connected", 0);
RETURN_FALSE;
}
valkey_glide_unsubscribe_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, valkey_glide->glide_client);
}
/* }}} */
/* {{{ proto array ValkeyGlideCluster::punsubscribe(array pats) */
PHP_METHOD(ValkeyGlideCluster, punsubscribe) {
valkey_glide_object* valkey_glide =
VALKEY_GLIDE_PHP_ZVAL_GET_OBJECT(valkey_glide_object, getThis());
if (!valkey_glide->glide_client) {
zend_throw_exception(get_valkey_glide_exception_ce(), "Client not connected", 0);
RETURN_FALSE;
}
valkey_glide_punsubscribe_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, valkey_glide->glide_client);
}
/* }}} */
/* Commands that do not interact with ValkeyGlide, but just report stuff about
* various options, etc */
/*
* Transaction handling
*/
/* {{{ proto bool ValkeyGlideCluster::multi() */
MULTI_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto bool ValkeyGlideCluster::pipeline() */
PIPELINE_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto bool ValkeyGlideCluster::watch() */
WATCH_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto bool ValkeyGlideCluster::unwatch() */
UNWATCH_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto array ValkeyGlideCluster::exec() */
EXEC_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto bool ValkeyGlideCluster::discard() */
DISCARD_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto ValkeyGlideCluster::scan(string master, long it [, string pat, long cnt]) */
SCAN_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlideCluster::sscan(string key, long it [string pat, long cnt]) */
SSCAN_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlideCluster::zscan(string key, long it [string pat, long cnt]) */
ZSCAN_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlideCluster::hscan(string key, long it [string pat, long cnt]) */
HSCAN_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlideCluster::flushdb(string key, [bool async])
* proto ValkeyGlideCluster::flushdb(array host_port, [bool async]) */
FLUSHDB_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlideCluster::flushall(string key, [bool async])
* proto ValkeyGlideCluster::flushall(array host_port, [bool async]) */
FLUSHALL_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto ValkeyGlideCluster::dbsize(string key)
* proto ValkeyGlideCluster::dbsize(array host_port) */
DBSIZE_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::info(string key, [string $arg])
* proto array ValkeyGlideCluster::info(array host_port, [string $arg]) */
INFO_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto array ValkeyGlideCluster::client('list')
* proto bool ValkeyGlideCluster::client('kill', $ipport)
* proto bool ValkeyGlideCluster::client('setname', $name)
* proto string ValkeyGlideCluster::client('getname')
*/
CLIENT_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
/* {{{ proto mixed ValkeyGlideCluster::config(string key, ...)
* proto mixed ValkeyGlideCluster::config(array host_port, ...) */
CONFIG_METHOD_IMPL(ValkeyGlideCluster)
/* }}} */
PHP_METHOD(ValkeyGlideCluster, publish) {
valkey_glide_object* valkey_glide =
VALKEY_GLIDE_PHP_ZVAL_GET_OBJECT(valkey_glide_object, getThis());
if (!valkey_glide->glide_client) {
zend_throw_exception(get_valkey_glide_exception_ce(), "Client not connected", 0);
RETURN_FALSE;
}
valkey_glide_publish_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, valkey_glide->glide_client);
}
/* {{{ proto mixed ValkeyGlideCluster::pubsub(string key, ...)
* proto mixed ValkeyGlideCluster::pubsub(array host_port, ...) */
PHP_METHOD(ValkeyGlideCluster, pubsub) {
valkey_glide_object* valkey_glide =
VALKEY_GLIDE_PHP_ZVAL_GET_OBJECT(valkey_glide_object, getThis());
if (!valkey_glide->glide_client) {
zend_throw_exception(get_valkey_glide_exception_ce(), "Client not connected", 0);
RETURN_FALSE;
}
valkey_glide_pubsub_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, valkey_glide->glide_client);
}
/* }}} */
/* {{{ proto array ValkeyGlideCluster::geohash(string key, string mem1, [string mem2...]) */
GEOHASH_METHOD_IMPL(ValkeyGlideCluster)
/* {{{ proto int ValkeyGlideCluster::geoadd(string key, float long float lat string mem, ...) */
GEOADD_METHOD_IMPL(ValkeyGlideCluster)