-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathredis.stub.php
More file actions
6013 lines (5660 loc) · 226 KB
/
redis.stub.php
File metadata and controls
6013 lines (5660 loc) · 226 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
<?php
/**
* @generate-function-entries
* @generate-legacy-arginfo
* @generate-class-entries
*/
class Redis {
/**
* Returned by `\Redis::type()` when the key does not exist or has a type
* we are not familiar with.
*
* @var int
* @cvalue REDIS_NOT_FOUND
*
*/
public const REDIS_NOT_FOUND = UNKNOWN;
/**
* Returned by `\Redis::type()` when the key is a string.
*
* @var int
* @cvalue REDIS_STRING
*
*/
public const REDIS_STRING = UNKNOWN;
/**
* Returned by `\Redis::type()` when the key is a set.
*
* @var int
* @cvalue REDIS_SET
*
*/
public const REDIS_SET = UNKNOWN;
/**
* Returned by `\Redis::type()` when the key is a list.
*
* @var int
* @cvalue REDIS_LIST
*
*/
public const REDIS_LIST = UNKNOWN;
/**
* Returned by `\Redis::type()` when the key is a sorted set.
*
* @var int
* @cvalue REDIS_ZSET
*
*/
public const REDIS_ZSET = UNKNOWN;
/**
* Returned by `\Redis::type()` when the key is a hash.
*
* @var int
* @cvalue REDIS_HASH
*
*/
public const REDIS_HASH = UNKNOWN;
/**
* Returned by `\Redis::type()` when the key is a stream.
*
* @var int
* @cvalue REDIS_STREAM
*
*/
public const REDIS_STREAM = UNKNOWN;
/**
* Returned by `\Redis::type()` when the key is a vector set.
*
* @var int
* @cvalue REDIS_VECTORSET
*
*/
public const REDIS_VECTORSET = UNKNOWN;
/**
* Returned from `\Redis::getMode()` when we're not in a multi or pipeline
* transaction.
*
* @var int
* @cvalue ATOMIC
*
*/
public const ATOMIC = UNKNOWN;
/**
* Returned from `\Redis::getMode()` when we're in a multi transaction.
*
* @var int
* @cvalue MULTI
*
*/
public const MULTI = UNKNOWN;
/**
* Returned from `\Redis::getMode()` when we're in a pipeline transaction.
*
* @var int
* @cvalue PIPELINE
*
*/
public const PIPELINE = UNKNOWN;
/**
* Used with `\Redis::setOption()` to specify the serializer to use
*
* @var int
* @cvalue REDIS_OPT_SERIALIZER
*
*/
public const OPT_SERIALIZER = UNKNOWN;
/**
* Used to set an automatic prefix for keys used in commands.
*
* @var int
* @cvalue REDIS_OPT_PREFIX
*
*/
public const OPT_PREFIX = UNKNOWN;
/**
* Used to set the read timeout for the connection.
*
* @var int
* @cvalue REDIS_OPT_READ_TIMEOUT
*
*/
public const OPT_READ_TIMEOUT = UNKNOWN;
/**
* Used to enable or disable TCP keepalive on the connection.
*
* @var int
* @cvalue REDIS_OPT_TCP_KEEPALIVE
*
*/
public const OPT_TCP_KEEPALIVE = UNKNOWN;
/**
* Used to set the compression algorithm to use for compressing
*
* @var int
* @cvalue REDIS_OPT_COMPRESSION
*
*/
public const OPT_COMPRESSION = UNKNOWN;
/**
* Causes PhpRedis to return the actual string in `+OK` style responses
* from Redis. If disabled those replies are just converted to boolean
* true.
*
* @var int
* @cvalue REDIS_OPT_REPLY_LITERAL
*
*/
public const OPT_REPLY_LITERAL = UNKNOWN;
/**
* Used to specify the compression level to use when compressing data.
*
* @var int
* @cvalue REDIS_OPT_COMPRESSION_LEVEL
*
*/
public const OPT_COMPRESSION_LEVEL = UNKNOWN;
/**
* Tells PhpRedis to return a NULL multi-bulk (`*-1\r\n`) response
* as `null` as opposed to an empty array.
*
* @var int
* @cvalue REDIS_OPT_NULL_MBULK_AS_NULL
*
*/
public const OPT_NULL_MULTIBULK_AS_NULL = UNKNOWN;
/**
* When enabled, this option tells PhpRedis to ignore purely numeric values
* when packing and unpacking data. This does not include numeric strings.
* If you want numeric strings to be ignored, typecast them to an int or
* float.
*
* The primary purpose of this option is to make it more ergonomic when
* setting keys that will later be incremented or decremented.
*
* Note: This option incurs a small performance penalty when reading data
* because we have to see if the data is a string representation of an int
* or float.
*
* @var int
* @cvalue REDIS_OPT_PACK_IGNORE_NUMBERS
*
* @example
* $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);
* $redis->setOption(Redis::OPT_PACK_IGNORE_NUMBERS, true);
* $redis->set('answer', 32);
*
* var_dump($redis->incrBy('answer', 10)); // int(42)
* var_dump($redis->get('answer')); // int(42)
*/
public const OPT_PACK_IGNORE_NUMBERS = UNKNOWN;
/**
* Sets the serializer to none (no serialization).
*
* @var int
* @cvalue REDIS_SERIALIZER_NONE
*
*/
public const SERIALIZER_NONE = UNKNOWN;
/**
* Sets the serializer to PHP's built-in `serialize()`/`unserialize()`
*
* @var int
* @cvalue REDIS_SERIALIZER_PHP
*
*/
public const SERIALIZER_PHP = UNKNOWN;
#ifdef HAVE_REDIS_IGBINARY
/**
* Sets the serializer to igbinary. Note that phpredis must be compiled
* with ighbinary support to use this serializer.
*
* @var int
* @cvalue REDIS_SERIALIZER_IGBINARY
*
*/
public const SERIALIZER_IGBINARY = UNKNOWN;
#endif
#ifdef HAVE_REDIS_MSGPACK
/**
* Sets the serializer to msgpack. Note that phpredis must be compiled
* with msgpack support to use this serializer.
*
* @var int
* @cvalue REDIS_SERIALIZER_MSGPACK
*
*/
public const SERIALIZER_MSGPACK = UNKNOWN;
#endif
/**
* Sets the serializer to JSON.
*
* @var int
* @cvalue REDIS_SERIALIZER_JSON
*
*/
public const SERIALIZER_JSON = UNKNOWN;
/**
* Disables compression.
*
* @var int
* @cvalue REDIS_COMPRESSION_NONE
*
*/
public const COMPRESSION_NONE = UNKNOWN;
#ifdef HAVE_REDIS_LZF
/**
* Sets the compression algorithm to LZF. PhpRedis must be compiled with
* lzf support but this serializer is bundled with the extension.
*
* @var int
* @cvalue REDIS_COMPRESSION_LZF
*
*/
public const COMPRESSION_LZF = UNKNOWN;
#endif
#ifdef HAVE_REDIS_ZSTD
/**
* Sets the compression algorithm to ZSTD. PhpRedis must be compiled with
* zstd support to use this serializer. This is often the best balance
* between speed and compression ratio.
*
* @var int
* @cvalue REDIS_COMPRESSION_ZSTD
*
*/
public const COMPRESSION_ZSTD = UNKNOWN;
#ifdef ZSTD_CLEVEL_DEFAULT
/**
* This constant represents the "default" compression level for ZSTD. If
* PhpRedis is compiled against a new enough ZSTD the value comes from the
* library, otherwise we just set it to 3.
*
* @var int
* @cvalue ZSTD_CLEVEL_DEFAULT
*
*/
public const COMPRESSION_ZSTD_DEFAULT = UNKNOWN;
#else
/**
* This constant represents the "default" compression level for ZSTD. If
* PhpRedis is compiled against a new enough ZSTD the value comes from the
* library, otherwise we just set it to 3.
*
* @var int
*
*/
public const COMPRESSION_ZSTD_DEFAULT = 3;
#endif
#if ZSTD_VERSION_NUMBER >= 10400
/**
* The minimum compression level ZSTD supports, which comes from the
* underlying ZSTD library if new enough. Otherwise we just set it to 1.
*
* @var int
* @cvalue ZSTD_minCLevel()
*
*/
public const COMPRESSION_ZSTD_MIN = UNKNOWN;
#else
/**
* The minimum compression level ZSTD supports, which comes from the
* underlying ZSTD library if new enough. Otherwise we just set it to 1.
*
* @var int
*
*/
public const COMPRESSION_ZSTD_MIN = 1;
#endif
/**
* The maximum compression level ZSTD supports, which comes from the
* underlying ZSTD library.
*
* @var int
* @cvalue ZSTD_maxCLevel()
*/
public const COMPRESSION_ZSTD_MAX = UNKNOWN;
#endif
#ifdef HAVE_REDIS_LZ4
/**
* Set the compression algorithm to LZ4. PhpRedis must be compiled with
* lz4 support to use this serializer. This algorithm is generally
* the fastest but has a lower compression ratio than ZSTD.
*
* @var int
* @cvalue REDIS_COMPRESSION_LZ4
*
*/
public const COMPRESSION_LZ4 = UNKNOWN;
#endif
/**
* Used with `\Redis::setOption()` to specify scan options.
*
* @var int
* @cvalue REDIS_OPT_SCAN
*
*/
public const OPT_SCAN = UNKNOWN;
/**
* When enabled, this option causes PhpRedis to automatically retry `SCAN`
* commands when Redis returns a non-zero cursor but no keys. This can
* happen due to the nature of Redis' scanning algorithm.
*
* @var int
* @cvalue REDIS_SCAN_RETRY
*
*/
public const SCAN_RETRY = UNKNOWN;
/**
* Then enabled, this option tells PhpRedis to not retry `SCAN` commands
* when Redis returns a non-zero cursor but no keys. This means that your
* code must handle this case itself.
*
* @var int
* @cvalue REDIS_SCAN_NORETRY
*
*/
public const SCAN_NORETRY = UNKNOWN;
/**
* Tells PhpRedis to prefix keys returned from `SCAN` commands with the
* currently set key prefix.
*
* @var int
* @cvalue REDIS_SCAN_PREFIX
*
*/
public const SCAN_PREFIX = UNKNOWN;
/**
* Tells PhpRedis to NOT prefix keys returned from `SCAN` commands with
* the currently set key prefix.
*
* @var int
* @cvalue REDIS_SCAN_NOPREFIX
*
*/
public const SCAN_NOPREFIX = UNKNOWN;
/**
* This is just the string "before" which is used with various list
* commands to indicate an insertion point.
*
* @var string
*
*/
public const BEFORE = "before";
/**
* This is just the string "after" which is used with various list commands
* to indicate an insertion point.
*
* @var string
*
*/
public const AFTER = "after";
/**
* This is just the string "left" which is used with various list commands
* such as `LMOVE`.
*
* @var string
*
*/
public const LEFT = "left";
/**
* This is just the string "right" which is used with various list commands
* such as `LMOVE`.
*
* @var string
*
*/
public const RIGHT = "right";
/**
* How many times should `PhpRedis` attempt to reconnect when we are
* disconnected.
*
* @var int
* @cvalue REDIS_OPT_MAX_RETRIES
*
*/
public const OPT_MAX_RETRIES = UNKNOWN;
/**
* Used to specify the backoff algorithm to use when reconnecting.
*
* @var int
* @cvalue REDIS_OPT_BACKOFF_ALGORITHM
*
*/
public const OPT_BACKOFF_ALGORITHM = UNKNOWN;
/**
* Default backoff - random delay before the first retry, then constant `base` ms.
*
* @var int
* @cvalue REDIS_BACKOFF_ALGORITHM_DEFAULT
*
*/
public const BACKOFF_ALGORITHM_DEFAULT = UNKNOWN;
/**
* Constant backoff - always sleep for exactly `base` ms (capped by `cap`).
*
* @var int
* @cvalue REDIS_BACKOFF_ALGORITHM_CONSTANT
*
*/
public const BACKOFF_ALGORITHM_CONSTANT = UNKNOWN;
/**
* Uniform backoff - randomly sleep between 0 and `base` ms for each retry.
*
* @var int
* @cvalue REDIS_BACKOFF_ALGORITHM_UNIFORM
*
*/
public const BACKOFF_ALGORITHM_UNIFORM = UNKNOWN;
/**
* Exponential backoff - doubles the delay every retry (up to 2^10) before `cap`.
*
* @var int
* @cvalue REDIS_BACKOFF_ALGORITHM_EXPONENTIAL
*
*/
public const BACKOFF_ALGORITHM_EXPONENTIAL = UNKNOWN;
/**
* Full jitter - exponential delay but pick a random value between 0 and that delay.
*
* @var int
* @cvalue REDIS_BACKOFF_ALGORITHM_FULL_JITTER
*
*/
public const BACKOFF_ALGORITHM_FULL_JITTER = UNKNOWN;
/**
* Equal jitter - half the exponential delay plus a random amount up to the other half.
*
* @var int
* @cvalue REDIS_BACKOFF_ALGORITHM_EQUAL_JITTER
*
*/
public const BACKOFF_ALGORITHM_EQUAL_JITTER = UNKNOWN;
/**
* Decorrelated jitter - pick a random delay between `base` and 3x the previous delay.
*
* @var int
* @cvalue REDIS_BACKOFF_ALGORITHM_DECORRELATED_JITTER
*
*/
public const BACKOFF_ALGORITHM_DECORRELATED_JITTER = UNKNOWN;
/**
* Backoff base - minimum delay in milliseconds that algorithms start from.
*
* @var int
* @cvalue REDIS_OPT_BACKOFF_BASE
*
*/
public const OPT_BACKOFF_BASE = UNKNOWN;
/**
* Backoff cap - maximum delay in milliseconds that any algorithm can reach.
*
* @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
*
*```php
*$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|null $options
*
* @return Redis
*
* @example
* $redis = new Redis(['host' => '127.0.0.1', 'port' => 6380]);
*
*/
public function __construct(?array $options = null);
/**
* Destructor to clean up the Redis object.
*
* This method will disconnect from Redis. If the connection is persistento
* it will be stashed for future reuse.
*
*/
public function __destruct();
/**
* Compress a value with the currently configured compressor (Redis::OPT_COMPRESSION)
* exactly the same way PhpRedis does before sending data to Redis.
*
* @see Redis::setOption()
*
* @param string $value The value to be compressed
* @return string The compressed result (or the original value if compression is disabled)
*
* @example
* $redis->_compress('payload');
*
*/
public function _compress(string $value): string;
/**
* Uncompress the provided argument using the compressor configured via
* Redis::setOption() (Redis::OPT_COMPRESSION).
*
* @see Redis::setOption()
*
* @param string $value The compressed value to uncompress.
* @return string The uncompressed result.
*
* @example
* $redis->_uncompress($redis->_compress('payload'));
*
*/
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
*
* @example
* $redis->_prefix('user:42');
*
*/
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
*
* @example
* $redis->_serialize(['answer' => 42]);
*
*/
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
*
* @example
* $redis->_unserialize($redis->_serialize(['answer' => 42]));
*
*/
public function _unserialize(string $value): mixed;
/**
* Pack the provided value by first serializing it (if Redis::OPT_SERIALIZER is set)
* and then compressing the serialized payload (if Redis::OPT_COMPRESSION is set),
* mirroring exactly what PhpRedis transmits to Redis.
*
* @param mixed $value The value to pack
* @return string The packed result having been serialized and
* compressed.
*
* @example
* $redis->_pack(['count' => 5]);
*
*/
public function _pack(mixed $value): string;
/**
* Compute the XXH3 digest of a PHP value after it has been `_pack`ed, producing
* the same digest Redis' DIGEST command would return for the stored value.
*
* @param mixed $value The value to compute the digest for.
* @return string The computed digest.
*
* @throws RedisException If XXH3 is not supported.
*
* @note This function requires PHP >= 8.1 which is the version PHP
* added support for XXH3 hashing and made the hash extension
* mandatory.
*
* @example
* $redis->_digest(['token' => 'abc']);
*
*/
public function _digest(mixed $value): string;
/**
* Unpack the provided value by first uncompressing it (if Redis::OPT_COMPRESSION
* is set) and then unserializing it (if Redis::OPT_SERIALIZER is set) to recover
* the original PHP value.
*
* @param string $value The value which has been serialized and compressed.
* @return mixed The uncompressed and deserialized value.
*
* @example
* $redis->_unpack($redis->_pack(['count' => 5]));
*
*/
public function _unpack(string $value): mixed;
/**
* Execute Redis ACL subcommands.
*
* @see https://redis.io/docs/latest/commands/acl/
*
* @example
* $redis->acl('list');
*/
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/docs/latest/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/docs/latest/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.
*
* @example
* $redis->auth('secret');
*
*/
public function auth(#[\SensitiveParameter] mixed $credentials): Redis|bool;
/**
* Execute a save of the Redis database in the background.
*
* @see https://redis.io/docs/latest/commands/bgsave/
*
* @return Redis|bool Whether the command was successful.
*
* @example
* $redis->bgSave();
*
*/
public function bgSave(): Redis|bool;
/**
* Asynchronously rewrite Redis' append-only file
*
* @see https://redis.io/docs/latest/commands/bgrewriteaof/
*
* @return Redis|bool Whether the command was successful.
*
* @example
* $redis->bgrewriteaof();
*
*/
public function bgrewriteaof(): Redis|bool;
/**
* @see https://redis.io/docs/latest/commands/waitaof/
*
* @return Redis|array|false
*
* @example
* $redis->waitaof(1, 1, 5000);
*
*/
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/docs/latest/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.
*
* @example
* $redis->bitcount('bitmap', 0, -1);
*
*/
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/docs/latest/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.
*
* @example
* $redis->bitpos('bitmap', true, 0, -1);
*
**/
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/docs/latest/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/docs/latest/commands/brpop/
* @see Redis::blPop()
*
* @example
* $redis->brPop(['queue:critical', 'queue:default'], 5);
*
*/
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/docs/latest/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.
*
* @example
* $redis->brpoplpush('queue:pending', 'queue:processing', 5);
*
*/
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/docs/latest/commands/bzpopmax/
*
* @param string|array $key 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/docs/latest/commands/bzpopmin/
* @see Redis::bzPopMax()
*
* @example
* $redis->bzPopMin(['scores:high', 'scores:low'], 1.5);
*
*/
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.
*
* @see https://redis.io/docs/latest/commands/bzmpop/
*
* @example
* $redis->bzmpop(1.5, ['scores:high', 'scores:low'], 'MIN', 2);
*
*/
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/docs/latest/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.
*
* @example
* $redis->zmpop(['scores:high', 'scores:low'], 'MAX', 2);
*
*/
public function zmpop(array $keys, string $from, int $count = 1): Redis|array|null|false;