-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
redis.stub.php
4641 lines (4330 loc) · 179 KB
/
redis.stub.php
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
<?php
/**
* @generate-function-entries
* @generate-legacy-arginfo
* @generate-class-entries
*/
class Redis {
/**
*
* @var int
* @cvalue REDIS_NOT_FOUND
*
*/
public const REDIS_NOT_FOUND = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_STRING
*
*/
public const REDIS_STRING = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_SET
*
*/
public const REDIS_SET = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_LIST
*
*/
public const REDIS_LIST = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_ZSET
*
*/
public const REDIS_ZSET = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_HASH
*
*/
public const REDIS_HASH = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_STREAM
*
*/
public const REDIS_STREAM = UNKNOWN;
/**
*
* @var int
* @cvalue ATOMIC
*
*/
public const ATOMIC = UNKNOWN;
/**
*
* @var int
* @cvalue MULTI
*
*/
public const MULTI = UNKNOWN;
/**
*
* @var int
* @cvalue PIPELINE
*
*/
public const PIPELINE = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_OPT_SERIALIZER
*
*/
public const OPT_SERIALIZER = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_OPT_PREFIX
*
*/
public const OPT_PREFIX = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_OPT_READ_TIMEOUT
*
*/
public const OPT_READ_TIMEOUT = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_OPT_TCP_KEEPALIVE
*
*/
public const OPT_TCP_KEEPALIVE = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_OPT_COMPRESSION
*
*/
public const OPT_COMPRESSION = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_OPT_REPLY_LITERAL
*
*/
public const OPT_REPLY_LITERAL = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_OPT_COMPRESSION_LEVEL
*
*/
public const OPT_COMPRESSION_LEVEL = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_OPT_NULL_MBULK_AS_NULL
*
*/
public const OPT_NULL_MULTIBULK_AS_NULL = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_SERIALIZER_NONE
*
*/
public const SERIALIZER_NONE = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_SERIALIZER_PHP
*
*/
public const SERIALIZER_PHP = UNKNOWN;
#ifdef HAVE_REDIS_IGBINARY
/**
*
* @var int
* @cvalue REDIS_SERIALIZER_IGBINARY
*
*/
public const SERIALIZER_IGBINARY = UNKNOWN;
#endif
#ifdef HAVE_REDIS_MSGPACK
/**
*
* @var int
* @cvalue REDIS_SERIALIZER_MSGPACK
*
*/
public const SERIALIZER_MSGPACK = UNKNOWN;
#endif
/**
*
* @var int
* @cvalue REDIS_SERIALIZER_JSON
*
*/
public const SERIALIZER_JSON = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_COMPRESSION_NONE
*
*/
public const COMPRESSION_NONE = UNKNOWN;
#ifdef HAVE_REDIS_LZF
/**
*
* @var int
* @cvalue REDIS_COMPRESSION_LZF
*
*/
public const COMPRESSION_LZF = UNKNOWN;
#endif
#ifdef HAVE_REDIS_ZSTD
/**
*
* @var int
* @cvalue REDIS_COMPRESSION_ZSTD
*
*/
public const COMPRESSION_ZSTD = UNKNOWN;
#ifdef ZSTD_CLEVEL_DEFAULT
/**
*
* @var int
* @cvalue ZSTD_CLEVEL_DEFAULT
*
*/
public const COMPRESSION_ZSTD_DEFAULT = UNKNOWN;
#else
/**
*
* @var int
*
*/
public const COMPRESSION_ZSTD_DEFAULT = 3;
#endif
#if ZSTD_VERSION_NUMBER >= 10400
/**
*
* @var int
* @cvalue ZSTD_minCLevel()
*
*/
public const COMPRESSION_ZSTD_MIN = UNKNOWN;
#else
/**
*
* @var int
*
*/
public const COMPRESSION_ZSTD_MIN = 1;
#endif
/**
* @var int
* @cvalue ZSTD_maxCLevel()
*/
public const COMPRESSION_ZSTD_MAX = UNKNOWN;
#endif
#ifdef HAVE_REDIS_LZ4
/**
*
* @var int
* @cvalue REDIS_COMPRESSION_LZ4
*
*/
public const COMPRESSION_LZ4 = UNKNOWN;
#endif
/**
*
* @var int
* @cvalue REDIS_OPT_SCAN
*
*/
public const OPT_SCAN = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_SCAN_RETRY
*
*/
public const SCAN_RETRY = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_SCAN_NORETRY
*
*/
public const SCAN_NORETRY = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_SCAN_PREFIX
*
*/
public const SCAN_PREFIX = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_SCAN_NOPREFIX
*
*/
public const SCAN_NOPREFIX = UNKNOWN;
/**
*
* @var string
*
*/
public const BEFORE = "before";
/**
*
* @var string
*
*/
public const AFTER = "after";
/**
*
* @var string
*
*/
public const LEFT = "left";
/**
*
* @var string
*
*/
public const RIGHT = "right";
/**
*
* @var int
* @cvalue REDIS_OPT_MAX_RETRIES
*
*/
public const OPT_MAX_RETRIES = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_OPT_BACKOFF_ALGORITHM
*
*/
public const OPT_BACKOFF_ALGORITHM = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_BACKOFF_ALGORITHM_DEFAULT
*
*/
public const BACKOFF_ALGORITHM_DEFAULT = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_BACKOFF_ALGORITHM_CONSTANT
*
*/
public const BACKOFF_ALGORITHM_CONSTANT = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_BACKOFF_ALGORITHM_UNIFORM
*
*/
public const BACKOFF_ALGORITHM_UNIFORM = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_BACKOFF_ALGORITHM_EXPONENTIAL
*
*/
public const BACKOFF_ALGORITHM_EXPONENTIAL = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_BACKOFF_ALGORITHM_FULL_JITTER
*
*/
public const BACKOFF_ALGORITHM_FULL_JITTER = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_BACKOFF_ALGORITHM_EQUAL_JITTER
*
*/
public const BACKOFF_ALGORITHM_EQUAL_JITTER = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_BACKOFF_ALGORITHM_DECORRELATED_JITTER
*
*/
public const BACKOFF_ALGORITHM_DECORRELATED_JITTER = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_OPT_BACKOFF_BASE
*
*/
public const OPT_BACKOFF_BASE = UNKNOWN;
/**
*
* @var int
* @cvalue REDIS_OPT_BACKOFF_CAP
*
*/
public const OPT_BACKOFF_CAP = UNKNOWN;
/**
* Create a new Redis instance. If passed sufficient information in the
* options array it is also possible to connect to an instance at the same
* time.
*
* **NOTE**: Below is an example options array with various setting
*
* $options = [
* 'host' => 'localhost',
* 'port' => 6379,
* 'readTimeout' => 2.5,
* 'connectTimeout' => 2.5,
* 'persistent' => true,
*
* // Valid formats: NULL, ['user', 'pass'], 'pass', or ['pass']
* 'auth' => ['phpredis', 'phpredis'],
*
* // See PHP stream options for valid SSL configuration settings.
* 'ssl' => ['verify_peer' => false],
*
* // How quickly to retry a connection after we time out or it closes.
* // Note that this setting is overridden by 'backoff' strategies.
* 'retryInterval' => 100,
*
* // Which backoff algorithm to use. 'decorrelated jitter' is
* // likely the best one for most solution, but there are many
* // to choose from:
* // REDIS_BACKOFF_ALGORITHM_DEFAULT
* // REDIS_BACKOFF_ALGORITHM_CONSTANT
* // REDIS_BACKOFF_ALGORITHM_UNIFORM
* // REDIS_BACKOFF_ALGORITHM_EXPONENTIAL
* // REDIS_BACKOFF_ALGORITHM_FULL_JITTER
* // REDIS_BACKOFF_ALGORITHM_EQUAL_JITTER
* // REDIS_BACKOFF_ALGORITHM_DECORRELATED_JITTER
* // 'base', and 'cap' are in milliseconds and represent the first
* // delay redis will use when reconnecting, and the maximum delay
* // we will reach while retrying.
* 'backoff' => [
* 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER,
* 'base' => 500,
* 'cap' => 750,
* ]
* ];
*
* Note: If you do wish to connect via the constructor, only 'host' is
* strictly required, which will cause PhpRedis to connect to that
* host on Redis' default port (6379).
*
*
* @see Redis::connect()
* @see https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
* @param array $options
*
* @return Redis
*/
public function __construct(?array $options = null);
public function __destruct();
/**
* Compress a value with the currently configured compressor as set with
* Redis::setOption().
*
* @see Redis::setOption()
*
* @param string $value The value to be compressed
* @return string The compressed result
*
*/
public function _compress(string $value): string;
/**
* Uncompress the provided argument that has been compressed with the
* currently configured compressor as set with Redis::setOption().
*
* @see Redis::setOption()
*
* @param string $value The compressed value to uncompress.
* @return string The uncompressed result.
*
*/
public function _uncompress(string $value): string;
/**
* Prefix the passed argument with the currently set key prefix as set
* with Redis::setOption().
*
* @param string $key The key/string to prefix
* @return string The prefixed string
*
*/
public function _prefix(string $key): string;
/**
* Serialize the provided value with the currently set serializer as set
* with Redis::setOption().
*
* @see Redis::setOption()
*
* @param mixed $value The value to serialize
* @return string The serialized result
*
*/
public function _serialize(mixed $value): string;
/**
* Unserialize the passed argument with the currently set serializer as set
* with Redis::setOption().
*
* @see Redis::setOption()
*
* @param string $value The value to unserialize
* @return mixed The unserialized result
*
*/
public function _unserialize(string $value): mixed;
/**
* Pack the provided value with the configured serializer and compressor
* as set with Redis::setOption().
*
* @param mixed $value The value to pack
* @return string The packed result having been serialized and
* compressed.
*/
public function _pack(mixed $value): string;
/**
* Unpack the provided value with the configured compressor and serializer
* as set with Redis::setOption().
*
* @param string $value The value which has been serialized and compressed.
* @return mixed The uncompressed and eserialized value.
*
*/
public function _unpack(string $value): mixed;
public function acl(string $subcmd, string ...$args): mixed;
/**
* Append data to a Redis STRING key.
*
* @param string $key The key in question
* @param mixed $value The data to append to the key.
*
* @return Redis|int|false The new string length of the key or false on failure.
*
* @see https://redis.io/commands/append
*
* @example
* $redis->set('foo', 'hello);
* $redis->append('foo', 'world');
*/
public function append(string $key, mixed $value): Redis|int|false;
/**
* Authenticate a Redis connection after its been established.
*
* $redis->auth('password');
* $redis->auth(['password']);
* $redis->auth(['username', 'password']);
*
* @see https://redis.io/commands/auth
*
* @param mixed $credentials A string password, or an array with one or two string elements.
* @return Redis|bool Whether the AUTH was successful.
*
*/
public function auth(#[\SensitiveParameter] mixed $credentials): Redis|bool;
/**
* Execute a save of the Redis database in the background.
*
* @see https://redis.io/commands/bgsave
*
* @return Redis|bool Whether the command was successful.
*/
public function bgSave(): Redis|bool;
/**
* Asynchronously rewrite Redis' append-only file
*
* @see https://redis.io/commands/bgrewriteaof
*
* @return Redis|bool Whether the command was successful.
*/
public function bgrewriteaof(): Redis|bool;
/**
* @see https://redis.io/commands/waitaof
*
* @return Redis|array
*/
public function waitaof(int $numlocal, int $numreplicas, int $timeout): Redis|array|false;
/**
* Count the number of set bits in a Redis string.
*
* @see https://redis.io/commands/bitcount/
*
* @param string $key The key in question (must be a string key)
* @param int $start The index where Redis should start counting. If omitted it
* defaults to zero, which means the start of the string.
* @param int $end The index where Redis should stop counting. If omitted it
* defaults to -1, meaning the very end of the string.
*
* @param bool $bybit Whether or not Redis should treat $start and $end as bit
* positions, rather than bytes.
*
* @return Redis|int|false The number of bits set in the requested range.
*
*/
public function bitcount(string $key, int $start = 0, int $end = -1, bool $bybit = false): Redis|int|false;
public function bitop(string $operation, string $deskey, string $srckey, string ...$other_keys): Redis|int|false;
/**
* Return the position of the first bit set to 0 or 1 in a string.
*
* @see https://redis.io/commands/bitpos/
*
* @param string $key The key to check (must be a string)
* @param bool $bit Whether to look for an unset (0) or set (1) bit.
* @param int $start Where in the string to start looking.
* @param int $end Where in the string to stop looking.
* @param bool $bybit If true, Redis will treat $start and $end as BIT values and not bytes, so if start
* was 0 and end was 2, Redis would only search the first two bits.
*
* @return Redis|int|false The position of the first set or unset bit.
**/
public function bitpos(string $key, bool $bit, int $start = 0, int $end = -1, bool $bybit = false): Redis|int|false;
/**
* Pop an element off the beginning of a Redis list or lists, potentially blocking up to a specified
* timeout. This method may be called in two distinct ways, of which examples are provided below.
*
* @see https://redis.io/commands/blpop/
*
* @param string|array $key_or_keys This can either be a string key or an array of one or more
* keys.
* @param string|float|int $timeout_or_key If the previous argument was a string key, this can either
* be an additional key, or the timeout you wish to send to
* the command.
*
* @return Redis|array|null|false Can return various things depending on command and data in Redis.
*
* @example
* $redis->blPop('list1', 'list2', 'list3', 1.5);
* $relay->blPop(['list1', 'list2', 'list3'], 1.5);
*/
public function blPop(string|array $key_or_keys, string|float|int $timeout_or_key, mixed ...$extra_args): Redis|array|null|false;
/**
* Pop an element off of the end of a Redis list or lists, potentially blocking up to a specified timeout.
* The calling convention is identical to Redis::blPop() so see that documentation for more details.
*
* @see https://redis.io/commands/brpop/
* @see Redis::blPop()
*
*/
public function brPop(string|array $key_or_keys, string|float|int $timeout_or_key, mixed ...$extra_args): Redis|array|null|false;
/**
* Pop an element from the end of a Redis list, pushing it to the beginning of another Redis list,
* optionally blocking up to a specified timeout.
*
* @see https://redis.io/commands/brpoplpush/
*
* @param string $src The source list
* @param string $dst The destination list
* @param int|float $timeout The number of seconds to wait. Note that you must be connected
* to Redis >= 6.0.0 to send a floating point timeout.
*
*/
public function brpoplpush(string $src, string $dst, int|float $timeout): Redis|string|false;
/**
* POP the maximum scoring element off of one or more sorted sets, blocking up to a specified
* timeout if no elements are available.
*
* Following are examples of the two main ways to call this method.
*
* **NOTE**: We recommend calling this function with an array and a timeout as the other strategy
* may be deprecated in future versions of PhpRedis
*
* @see https://redis.io/commands/bzpopmax
*
* @param string|array $key_or_keys Either a string key or an array of one or more keys.
* @param string|int $timeout_or_key If the previous argument was an array, this argument
* must be a timeout value. Otherwise it could also be
* another key.
* @param mixed $extra_args Can consist of additional keys, until the last argument
* which needs to be a timeout.
*
* @return Redis|array|false The popped elements.
*
* @example
* $redis->bzPopMax('key1', 'key2', 'key3', 1.5);
* $redis->bzPopMax(['key1', 'key2', 'key3'], 1.5);
*/
public function bzPopMax(string|array $key, string|int $timeout_or_key, mixed ...$extra_args): Redis|array|false;
/**
* POP the minimum scoring element off of one or more sorted sets, blocking up to a specified timeout
* if no elements are available
*
* This command is identical in semantics to bzPopMax so please see that method for more information.
*
* @see https://redis.io/commands/bzpopmin
* @see Redis::bzPopMax()
*
*/
public function bzPopMin(string|array $key, string|int $timeout_or_key, mixed ...$extra_args): Redis|array|false;
/**
* POP one or more elements from one or more sorted sets, blocking up to a specified amount of time
* when no elements are available.
*
* @param float $timeout How long to block if there are no element available
* @param array $keys The sorted sets to pop from
* @param string $from The string 'MIN' or 'MAX' (case insensitive) telling Redis whether you wish to
* pop the lowest or highest scoring members from the set(s).
* @param int $count Pop up to how many elements.
*
* @return Redis|array|null|false This function will return an array of popped elements, or false
* depending on whether any elements could be popped within the
* specified timeout.
*
* NOTE: If Redis::OPT_NULL_MULTIBULK_AS_NULL is set to true via Redis::setOption(), this method will
* instead return NULL when Redis doesn't pop any elements.
*/
public function bzmpop(float $timeout, array $keys, string $from, int $count = 1): Redis|array|null|false;
/**
* POP one or more of the highest or lowest scoring elements from one or more sorted sets.
*
* @see https://redis.io/commands/zmpop
*
* @param array $keys One or more sorted sets
* @param string $from The string 'MIN' or 'MAX' (case insensitive) telling Redis whether you want to
* pop the lowest or highest scoring elements.
* @param int $count Pop up to how many elements at once.
*
* @return Redis|array|null|false An array of popped elements or false if none could be popped.
*/
public function zmpop(array $keys, string $from, int $count = 1): Redis|array|null|false;
/**
* Pop one or more elements from one or more Redis LISTs, blocking up to a specified timeout when
* no elements are available.
*
* @see https://redis.io/commands/blmpop
*
* @param float $timeout The number of seconds Redis will block when no elements are available.
* @param array $keys One or more Redis LISTs to pop from.
* @param string $from The string 'LEFT' or 'RIGHT' (case insensitive), telling Redis whether
* to pop elements from the beginning or end of the LISTs.
* @param int $count Pop up to how many elements at once.
*
* @return Redis|array|null|false One or more elements popped from the list(s) or false if all LISTs
* were empty.
*/
public function blmpop(float $timeout, array $keys, string $from, int $count = 1): Redis|array|null|false;
/**
* Pop one or more elements off of one or more Redis LISTs.
*
* @see https://redis.io/commands/lmpop
*
* @param array $keys An array with one or more Redis LIST key names.
* @param string $from The string 'LEFT' or 'RIGHT' (case insensitive), telling Redis whether to pop\
* elements from the beginning or end of the LISTs.
* @param int $count The maximum number of elements to pop at once.
*
* @return Redis|array|null|false One or more elements popped from the LIST(s) or false if all the LISTs
* were empty.
*
*/
public function lmpop(array $keys, string $from, int $count = 1): Redis|array|null|false;
/**
* Reset any last error on the connection to NULL
*
* @see Redis::getLastError()
* @return bool This should always return true or throw an exception if we're not connected.
*
* @example
* $redis = new Redis(['host' => 'localhost']);
* $redis->set('string', 'this_is_a_string');
* $redis->smembers('string');
* var_dump($redis->getLastError());
* $redis->clearLastError();
* var_dump($redis->getLastError());
*/
public function clearLastError(): bool;
public function client(string $opt, mixed ...$args): mixed;
public function close(): bool;
public function command(?string $opt = null, mixed ...$args): mixed;
/**
* Execute the Redis CONFIG command in a variety of ways.
*
* What the command does in particular depends on the `$operation` qualifier.
* Operations that PhpRedis supports are: RESETSTAT, REWRITE, GET, and SET.
*
* @param string $operation The CONFIG operation to execute (e.g. GET, SET, REWRITE).
* @param array|string|null $key_or_settings One or more keys or values.
* @param string $value The value if this is a `CONFIG SET` operation.
* @see https://redis.io/commands/config
*
* @example
* $redis->config('GET', 'timeout');
* $redis->config('GET', ['timeout', 'databases']);
* $redis->config('SET', 'timeout', 30);
* $redis->config('SET', ['timeout' => 30, 'loglevel' => 'warning']);
*/
public function config(string $operation, array|string|null $key_or_settings = null, ?string $value = null): mixed;
public function connect(string $host, int $port = 6379, float $timeout = 0, ?string $persistent_id = null,
int $retry_interval = 0, float $read_timeout = 0, ?array $context = null): bool;
/**
* Make a copy of a key.
*
* $redis = new Redis(['host' => 'localhost']);
*
* @param string $src The key to copy
* @param string $dst The name of the new key created from the source key.
* @param array $options An array with modifiers on how COPY should operate.
* <code>
* $options = [
* 'REPLACE' => true|false # Whether to replace an existing key.
* 'DB' => int # Copy key to specific db.
* ];
* </code>
*
* @return Redis|bool True if the copy was completed and false if not.
*
* @see https://redis.io/commands/copy
*
* @example
* $redis->pipeline()
* ->select(1)
* ->del('newkey')
* ->select(0)
* ->del('newkey')
* ->mset(['source1' => 'value1', 'exists' => 'old_value'])
* ->exec();
*
* var_dump($redis->copy('source1', 'newkey'));
* var_dump($redis->copy('source1', 'newkey', ['db' => 1]));
* var_dump($redis->copy('source1', 'exists'));
* var_dump($redis->copy('source1', 'exists', ['REPLACE' => true]));
*/
public function copy(string $src, string $dst, ?array $options = null): Redis|bool;
/**
* Return the number of keys in the currently selected Redis database.
*
* @see https://redis.io/commands/dbsize
*
* @return Redis|int The number of keys or false on failure.
*
* @example
* $redis = new Redis(['host' => 'localhost']);
* $redis->flushdb();
* $redis->set('foo', 'bar');
* var_dump($redis->dbsize());
* $redis->mset(['a' => 'a', 'b' => 'b', 'c' => 'c', 'd' => 'd']);
* var_dump($redis->dbsize());
*/
public function dbSize(): Redis|int|false;
public function debug(string $key): Redis|string;
/**
* Decrement a Redis integer by 1 or a provided value.
*
* @param string $key The key to decrement
* @param int $by How much to decrement the key. Note that if this value is
* not sent or is set to `1`, PhpRedis will actually invoke
* the 'DECR' command. If it is any value other than `1`
* PhpRedis will actually send the `DECRBY` command.
*
* @return Redis|int|false The new value of the key or false on failure.
*
* @see https://redis.io/commands/decr
* @see https://redis.io/commands/decrby
*
* @example $redis->decr('counter');
* @example $redis->decr('counter', 2);
*/
public function decr(string $key, int $by = 1): Redis|int|false;
/**
* Decrement a redis integer by a value
*
* @param string $key The integer key to decrement.
* @param int $value How much to decrement the key.
*
* @return Redis|int|false The new value of the key or false on failure.
*
* @see https://redis.io/commands/decrby
*
* @example $redis->decrby('counter', 1);
* @example $redis->decrby('counter', 2);
*/
public function decrBy(string $key, int $value): Redis|int|false;
/**
* Delete one or more keys from Redis.
*
* This method can be called in two distinct ways. The first is to pass a single array
* of keys to delete, and the second is to pass N arguments, all names of keys. See
* below for an example of both strategies.
*
* @param array|string $key_or_keys Either an array with one or more key names or a string with
* the name of a key.
* @param string $other_keys One or more additional keys passed in a variadic fashion.
*
* @return Redis|int|false The number of keys that were deleted
*
* @see https://redis.io/commands/del
*
* @example $redis->del('key:0', 'key:1');
* @example $redis->del(['key:2', 'key:3', 'key:4']);
*/
public function del(array|string $key, string ...$other_keys): Redis|int|false;
/**
* @deprecated
* @alias Redis::del
*/
public function delete(array|string $key, string ...$other_keys): Redis|int|false;
/**
* Discard a transaction currently in progress.
*
* @return Redis|bool True if we could discard the transaction.
*
* @example
* $redis->getMode();
* $redis->set('foo', 'bar');
* $redis->discard();
* $redis->getMode();
*/
public function discard(): Redis|bool;
/**
* Dump Redis' internal binary representation of a key.
*
* <code>
* $redis->zRange('new-zset', 0, -1, true);
* </code>
*
* @param string $key The key to dump.
*
* @return Redis|string A binary string representing the key's value.
*
* @see https://redis.io/commands/dump
*
* @example
* $redis->zadd('zset', 0, 'zero', 1, 'one', 2, 'two');
* $binary = $redis->dump('zset');
* $redis->restore('new-zset', 0, $binary);
*/