Tiện ích mở rộng phpredis cung cấp API để giao tiếp với kho lưu trữ khóa-giá trị Redis. Nó được phát hành theo Giấy phép PHP, phiên bản 3. 01. Mã này đã được Owlient phát triển và duy trì từ tháng 11 năm 2009 đến tháng 3 năm 2011
Bạn có thể gửi nhận xét, bản vá lỗi, câu hỏi tại đây trên github, tới michael. máy xay @ gmail. com [Twitter, Mastodon], p. yatsukhnenko@gmail. com [@yatsukhnenko], or n. favrefelix@gmail. com [@yowgi]
Tài liệu API
Đây là một công việc đang được tiến hành, nhưng cuối cùng sẽ thay thế MỘT README ĐỂ QUY ĐỊNH TẤT CẢ các tài liệu của chúng tôi
Hỗ trợ dự án
PhpRedis sẽ luôn là phần mềm nguồn mở và miễn phí, nhưng nếu bạn hoặc công ty của bạn thấy nó hữu ích, vui lòng cân nhắc hỗ trợ dự án. Việc phát triển một thư viện lớn, phức tạp và hiệu quả như PhpRedis cần rất nhiều thời gian và công sức, và sự hỗ trợ sẽ được đánh giá cao. ❤️
Cách tốt nhất để hỗ trợ dự án là thông qua các nhà tài trợ GitHub. Nhiều bậc phần thưởng cấp quyền truy cập vào kênh chùng của chúng tôi, nơi tôi và Pavlo thường xuyên có mặt để trả lời các câu hỏi. Ngoài ra, điều này sẽ cho phép bạn cung cấp phản hồi về các bản sửa lỗi và tính năng mới cần ưu tiên
Bạn cũng có thể đóng góp một lần với
nhà tài trợ
Table of contentsInstallation
For everything you should need to install PhpRedis on your system, see the INSTALL. md page
PHP Session handler
phpredis can be used to store PHP sessions. To do this, configure
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
12 and # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
13 in your php. ini to tell phpredis where to store the sessionssession.save_handler = redis
session.save_path = "tcp://host1:6379?weight=1, tcp://host2:6379?weight=2&timeout=2.5, tcp://host3:6379?weight=2&read_timeout=2.5"
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
13 can have a simple # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
15 format too, but you need to provide the # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
16 scheme if you want to use the parameters. The following parameters are available- weight [integer]. the weight of a host is used in comparison with the others in order to customize the session distribution on several hosts. If host A has twice the weight of host B, it will get twice the amount of sessions. In the example, host1 stores 20% of all the sessions [1/[1+2+2]] while host2 and host3 each store 40% [2/[1+2+2]]. The target host is determined once and for all at the start of the session, and doesn't change. The default weight is 1
- timeout [float]. the connection timeout to a redis host, expressed in seconds. If the host is unreachable in that amount of time, the session storage will be unavailable for the client. The default timeout is very high [86400 seconds]
- persistent [integer, should be 1 or 0]. defines if a persistent connection should be used
- prefix [string, defaults to "PHPREDIS_SESSION. "]. used as a prefix to the Redis key in which the session is stored. The key is composed of the prefix followed by the session ID
- auth [string, or an array with one or two elements]. used to authenticate with the server prior to sending commands
- database [integer]. selects a different database
Sessions have a lifetime expressed in seconds and stored in the INI variable "session. gc_maxlifetime". Bạn có thể thay đổi nó bằng
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
17. Trình xử lý phiên yêu cầu phiên bản Redis hỗ trợ các tùy chọn # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
18 và # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
19 của lệnh # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
20 [ít nhất 2. 6. 12]. phpredis cũng có thể kết nối với một ổ cắm tên miền unix. # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
21khóa phiên
Ủng hộ. Tính năng khóa hiện chỉ được hỗ trợ cho thiết lập Redis với phiên bản chính duy nhất [e. g. môi trường Sentinel chính/nô lệ cổ điển]. Vì vậy, khóa có thể không hoạt động bình thường trong môi trường RedisArray hoặc RedisCluster
Các biến INI sau có thể được sử dụng để định cấu hình khóa phiên
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
Running the unit tests
phpredis uses a small custom unit test suite for testing functionality of the various classes. Để chạy thử nghiệm, chỉ cần làm như sau
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
Note that it is possible to run only tests which match a substring of the test itself by passing the additional argument '--test ' when invoking
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
Classes and methodsUsage
Class Redis
Description. Creates a Redis client
Example$redis = new Redis[];
Starting from version 6. 0. 0 it's possible to specify configuration options. This allows to connect lazily to the server without explicitly invoking
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
22 commandExample$redis = new Redis[[ 'host' => '127.0.0.1', 'port' => 6379, 'connectTimeout' => 2.5, 'auth' => ['phpredis', 'phpredis'], 'ssl' => ['verify_peer' => false], 'backoff' => [ 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, 'base' => 500, 'cap' => 750, ], ]];Parameters
host. chuỗi. can be a host, or the path to a unix domain socket
port. int [default is 6379, should be -1 for unix domain socket]
connectTimeout. float, value in seconds [default is 0 meaning unlimited]
retryInterval. int, value in milliseconds [optional]
readTimeout. float, value in seconds [default is 0 meaning unlimited]
persistent. mixed, if value is string then it used as persistend id, else value casts to boolean
auth. mixed, authentication information
ssl. array, SSL context options
Class RedisException
phpredis throws a object if it can't reach the Redis server. That can happen in case of connectivity issues, if the Redis service is down, or if the redis host is overloaded. In any other problematic case that does not involve an unreachable server [such as a key not existing, an invalid command, etc], phpredis will return
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23Predefined constants
Description. Available Redis Constants
Redis data types, as returned by
Redis::REDIS_STRING - String
Redis::REDIS_SET - Set
Redis::REDIS_LIST - List
Redis::REDIS_ZSET - Sorted set
Redis::REDIS_HASH - Hash
Redis::REDIS_NOT_FOUND - Not found / other
@TODO. OPT_SERIALIZER, AFTER, BEFORE,
Connection
- - Connect to a server
- - Connect to a server [persistent]
- - Authenticate to the server
- - Change the selected database for the current connection
- - Swaps two Redis databases
- - Close the connection
- - Set client option
- - Get client option
- - Ping the server
- - Echo the given string
connect, open
Description. Kết nối với một phiên bản Redis
Parametershost. string. can be a host, or the path to a unix domain socket. Starting from version 5. 0. 0 it is possible to specify schema
port. int, optional
timeout. float, value in seconds [optional, default is 0 meaning it will use default_socket_timeout]
reserved. should be '' if retry_interval is specified
retry_interval. int, value in milliseconds [optional]
read_timeout. float, value in seconds [optional, default is 0 meaning it will use default_socket_timeout]
others. array, with PhpRedis >= 5. 3. 0, it allows setting auth and stream configuration
BOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 on success, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 on errorExample$redis->connect['127.0.0.1', 6379]; $redis->connect['127.0.0.1']; // port 6379 by default $redis->connect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->connect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->connect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout. $redis->connect['/tmp/redis.sock']; // unix domain socket. $redis->connect['127.0.0.1', 6379, 1, '', 100]; // 1 sec timeout, 100ms delay between reconnection attempts. $redis->connect['/tmp/redis.sock', 0, 1.5, NULL, 0, 1.5]; // Unix socket with 1.5s timeouts [connect and read] /* With PhpRedis >= 5.3.0 you can specify authentication and stream information on connect */ $redis->connect['127.0.0.1', 6379, 1, '', 0, 0, ['auth' => ['phpredis', 'phpredis']]];
Note.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
26 is an alias for # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
22 and will be removed in future versions of phprediskết nối, mở
Sự miêu tả. Kết nối với phiên bản Redis hoặc sử dụng lại kết nối đã được thiết lập với
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
28/# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
29Kết nối sẽ không bị đóng khi kết thúc yêu cầu cho đến khi quá trình php kết thúc. So be prepared for too many open FD's errors [specially on redis server side] when using persistent connections on many servers connecting to one redis server
Also more than one persistent connection can be made identified by either host + port + timeout or host + persistent_id or unix socket + timeout
Starting from version 4. 2. 1, it became possible to use connection pooling by setting INI variable
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
30 to 1This feature is not available in threaded versions.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
28 and # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
29 then working like their non persistent equivalentsParametershost. string. can be a host, or the path to a unix domain socket. Starting from version 5. 0. 0 it is possible to specify schema
port. int, optional
timeout. float, value in seconds [optional, default is 0 meaning it will use default_socket_timeout]
persistent_id. string. identity for the requested persistent connection
retry_interval. int, value in milliseconds [optional]
read_timeout. float, value in seconds [optional, default is 0 meaning it will use default_socket_timeout]
BOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 on success, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 on errorExample$redis->pconnect['127.0.0.1', 6379]; $redis->pconnect['127.0.0.1']; // port 6379 by default - same connection like before. $redis->pconnect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->pconnect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->pconnect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout and would be another connection than the two before. $redis->pconnect['127.0.0.1', 6379, 2.5, 'x']; // x is sent as persistent_id and would be another connection than the three before. $redis->pconnect['/tmp/redis.sock']; // unix domain socket - would be another connection than the four before.
Note.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
29 is an alias for # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
28 and will be removed in future versions of phpredisauth
Description. Authenticate the connection using a password or a username and password. Warning. The password is sent in plain-text over the network
ParametersMIXED. password
Return valueBOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 if the connection is authenticated, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 otherwiseNote. In order to authenticate with a username and password you need Redis >= 6. 0
Example/* Authenticate with the password 'foobared' */ $redis->auth['foobared']; /* Authenticate with the username 'phpredis', and password 'haxx00r' */ $redis->auth[['phpredis', 'haxx00r']]; /* Authenticate with the password 'foobared' */ $redis->auth[['foobared']]; /* You can also use an associative array specifying user and pass */ $redis->auth[['user' => 'phpredis', 'pass' => 'phpredis']]; $redis->auth[['pass' => 'phpredis']];
select
Description. Change the selected database for the current connection
ParametersINTEGER. dbindex, the database number to switch to
Return value# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 in case of success, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of failureExampleSee method for example.
swapdb
Description. Swap one Redis database with another atomically
ParametersINTEGER. db1
INTEGER. db2
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 on success and # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 on failureNote. Requires Redis >= 4. 0. 0
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
0close
Description. Disconnects from the Redis instance
Note. Closing a persistent connection requires PhpRedis >= 4. 2. 0
ParametersNone
Return valueBOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 on success, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 on failuresetOption
Description. Set client option
Parametersparameter name
parameter value
BOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 on success, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 on errorExample; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
1getOption
Description. Get client option
Parametersparameter name
Return valueParameter value
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
2ping
Description. Check the current connection status
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
3Return valueMixed. This method returns
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 on success, or the passed string if called with an argumentExample; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
4Note. Prior to PhpRedis 5. 0. 0 lệnh này chỉ đơn giản là trả về chuỗi
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
48echo
Sự miêu tả. Gửi một chuỗi tới Redis, Redis trả lời bằng cùng một chuỗi
ParametersCHUỖI. Tin nhắn để gửi
Return valueSTRING. the same message
Retry and backoff
Maximum retries
You can set and get the maximum retries upon connection issues using the
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
49 option. Note that this is the number of retries, meaning if you set this option to n, there will be a maximum n+1 attemps overall. Defaults to 10Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
5Backoff algorithms
You can set the backoff algorithm using the
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
50 option and choose among the following algorithms described in this blog post by Marc Brooker from AWS. Exponential Backoff And Jitter- Default.
51# Run tests for Redis class [note this is the default] php tests/TestRedis.php --class Redis # Run tests for RedisArray class tests/mkring.sh start php tests/TestRedis.php --class RedisArray tests/mkring.sh stop # Run tests for the RedisCluster class tests/make-cluster.sh start php tests/TestRedis.php --class RedisCluster tests/make-cluster.sh stop # Run tests for RedisSentinel class php tests/TestRedis.php --class RedisSentinel
- Decorrelated jitter.
52# Run tests for Redis class [note this is the default] php tests/TestRedis.php --class Redis # Run tests for RedisArray class tests/mkring.sh start php tests/TestRedis.php --class RedisArray tests/mkring.sh stop # Run tests for the RedisCluster class tests/make-cluster.sh start php tests/TestRedis.php --class RedisCluster tests/make-cluster.sh stop # Run tests for RedisSentinel class php tests/TestRedis.php --class RedisSentinel
- Full jitter.
53# Run tests for Redis class [note this is the default] php tests/TestRedis.php --class Redis # Run tests for RedisArray class tests/mkring.sh start php tests/TestRedis.php --class RedisArray tests/mkring.sh stop # Run tests for the RedisCluster class tests/make-cluster.sh start php tests/TestRedis.php --class RedisCluster tests/make-cluster.sh stop # Run tests for RedisSentinel class php tests/TestRedis.php --class RedisSentinel
- Equal jitter.
54# Run tests for Redis class [note this is the default] php tests/TestRedis.php --class Redis # Run tests for RedisArray class tests/mkring.sh start php tests/TestRedis.php --class RedisArray tests/mkring.sh stop # Run tests for the RedisCluster class tests/make-cluster.sh start php tests/TestRedis.php --class RedisCluster tests/make-cluster.sh stop # Run tests for RedisSentinel class php tests/TestRedis.php --class RedisSentinel
- Exponential.
55# Run tests for Redis class [note this is the default] php tests/TestRedis.php --class Redis # Run tests for RedisArray class tests/mkring.sh start php tests/TestRedis.php --class RedisArray tests/mkring.sh stop # Run tests for the RedisCluster class tests/make-cluster.sh start php tests/TestRedis.php --class RedisCluster tests/make-cluster.sh stop # Run tests for RedisSentinel class php tests/TestRedis.php --class RedisSentinel
- Uniform.
56# Run tests for Redis class [note this is the default] php tests/TestRedis.php --class Redis # Run tests for RedisArray class tests/mkring.sh start php tests/TestRedis.php --class RedisArray tests/mkring.sh stop # Run tests for the RedisCluster class tests/make-cluster.sh start php tests/TestRedis.php --class RedisCluster tests/make-cluster.sh stop # Run tests for RedisSentinel class php tests/TestRedis.php --class RedisSentinel
- Constant.
57# Run tests for Redis class [note this is the default] php tests/TestRedis.php --class Redis # Run tests for RedisArray class tests/mkring.sh start php tests/TestRedis.php --class RedisArray tests/mkring.sh stop # Run tests for the RedisCluster class tests/make-cluster.sh start php tests/TestRedis.php --class RedisCluster tests/make-cluster.sh stop # Run tests for RedisSentinel class php tests/TestRedis.php --class RedisSentinel
These algorithms depend on the base and cap parameters, both in milliseconds, which you can set using the
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
58 and # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
59 options, respectivelyExample; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
6Server
- - Manage Redis ACLs
- - Asynchronously rewrite the append-only file
- - Asynchronously save the dataset to disk [in background]
- - Get or Set the Redis server configuration parameters
- - Return the number of keys in selected database
- - Remove all keys from all databases
- - Remove all keys from the current database
- - Get information and statistics about the server
- - Get the timestamp of the last disk save
- - Synchronously save the dataset to disk [wait to complete]
- - Make the server a slave of another instance, or promote it to master
- - Return the current server time
- - Access the Redis slowLog entries
acl
Description. Thực thi lệnh Redis ACL
Parametersvariable. Minumum of one argument for
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
60 and two for # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
61Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
7Note. In order to user the
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
62 command you must be communicating with Redis >= 6. 0 and be logged into an account that has access to administration commands such as ACL. Please reference this tutorial for an overview of Redis 6 ACLs and the redis command reference for every ACL subcommandNote. If you are connecting to Redis server >= 4. 0. 0 you can remove a key with the
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
63 method in the exact same way you would use # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
64. The Redis unlink command is non-blocking and will perform the actual deletion asynchronouslybgRewriteAOF
Description. Start the background rewrite of AOF [Append-Only File]
ParametersNone
Return valueBOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 in case of success, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of failureExample; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
8bgSave
Description. Asynchronously save the dataset to disk [in background]
ParametersNone
Return valueBOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 in case of success, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of failure. If a save is already running, this command will fail and return # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
9cấu hình
Sự miêu tả. Nhận hoặc Đặt tham số cấu hình máy chủ Redis
Prototype# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
0Return valueMảng kết hợp cho
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
70, [các] khóa -> [các] giá trịbool cho
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
20, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
72 và # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
73ví dụ# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
1dbSize
Sự miêu tả. Trả về số lượng khóa trong cơ sở dữ liệu đã chọn
ParametersNone
Return valuesố nguyên. Kích thước DB, theo số lượng khóa
Example# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
2tuôn raTất cả
Sự miêu tả. Xóa tất cả các khóa khỏi tất cả các cơ sở dữ liệu
Parametersasync [bool] yêu cầu phiên bản máy chủ 4. 0. 0 hoặc cao hơn
Return valueBOOL. Luôn luôn
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24Example# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
3tuôn raDb
Sự miêu tả. Xóa tất cả các khóa khỏi cơ sở dữ liệu hiện tại
Prototype# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
4Return valueBOOL. Lệnh này trả về true nếu thành công và false nếu thất bại
Example# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
5thông tin
Sự miêu tả. Nhận thông tin và số liệu thống kê về máy chủ
Trả về một mảng kết hợp cung cấp thông tin về máy chủ. Không truyền đối số cho INFO sẽ gọi lệnh REDIS INFO tiêu chuẩn, trả về thông tin như sau
- redis_version
- Arch_bits
- thời gian hoạt động_in_giây
- thời gian hoạt động_trong_ngày
- connect_clients
- kết nối_slaves
- used_memory
- changes_since_last_save
- bgsave_in_progress
- last_save_time
- tổng_kết nối_đã nhận
- tổng_lệnh_đã xử lý
- vai diễn
Bạn có thể chuyển nhiều tùy chọn cho INFO [theo tài liệu Redis], điều này sẽ sửa đổi những gì được trả về
Parametersquyền mua. Tùy chọn cung cấp redis [e. g. "THỐNG KÊ LỆNH", "CPU"]
Example# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
6lần lưu cuối cùng
Sự miêu tả. Trả về dấu thời gian của lần lưu đĩa cuối cùng
ParametersNone
Return valueINT. dấu thời gian
Example# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
7tiết kiệm
Sự miêu tả. Lưu đồng bộ tập dữ liệu vào đĩa [chờ hoàn tất]
ParametersNone
Return valueBOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 in case of success, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of failure. If a save is already running, this command will fail and return # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23Example# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
8nô lệ của
Sự miêu tả. Thay đổi trạng thái nô lệ
ParametersMáy chủ [chuỗi] và cổng [int] hoặc không có tham số nào ngừng làm nô lệ
Return valueBOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 in case of success, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of failureExample# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
9thời gian
Sự miêu tả. Trả về thời gian máy chủ hiện tại
Parameters[không ai]
Return valueNếu thành công, thời gian sẽ quay trở lại dưới dạng một mảng kết hợp với phần tử 0 là dấu thời gian unix và phần tử một là micro giây
ví dụ# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
0Nhật ký chậm
Sự miêu tả. Truy cập Redis SlowLog
ParametersHoạt động [chuỗi]. Đây có thể là
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
70, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
81 hoặc # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
82Độ dài [số nguyên], tùy chọn. Nếu thực hiện lệnh
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
83, bạn có thể truyền độ dài tùy chọnReturn valueGiá trị trả về của SLOWLOG sẽ phụ thuộc vào thao tác nào được thực hiện. CHẬM NHẬT KÝ. Mảng các mục nhập slowLog, được cung cấp bởi Redis SLOGLOG LEN. Số nguyên, độ dài của slowLog SLOWLOG RESET. Boolean, tùy thuộc vào thành công
ví dụ# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
1Chìa khóa và Chuỗi
Dây
- - Nối một giá trị vào một khóa
- - Đếm các bit đã đặt trong một chuỗi
- - Thực hiện các hoạt động bitwise giữa các chuỗi
- - Giảm giá trị của khóa
- - Lấy giá trị của một khóa
- - Trả về giá trị bit ở phần bù trong giá trị chuỗi được lưu trữ tại khóa
- - Lấy một chuỗi con của chuỗi được lưu trữ tại một khóa
- - Đặt giá trị chuỗi của khóa và trả về giá trị cũ của nó
- - Tăng giá trị của khóa
- - Tăng giá trị float của một khóa theo số lượng đã cho
- - Get the values of all the given keys
- - Set multiple keys to multiple values
- - Set the string value of a key
- - Sets or clears the bit at offset in the string value stored at key
- - Set the value and expiration of a key
- - Set the value of a key, only if the key does not exist
- - Overwrite part of a string at key starting at the specified offset
- - Get the length of the value stored in a key
Keys
- - Delete a key
- - Return a serialized version of the value stored at the specified key
- - Determine if a key exists
- - Set a key's time to live in seconds
- - Set the expiration for a key as a UNIX timestamp
- - Find all keys matching the given pattern
- - Scan for keys in the keyspace [Redis >= 2. 8. 0]
- - Atomically transfer a key from a Redis instance to another one
- - Move a key to another database
- - Inspect the internals of Redis objects
- - Remove the expiration from a key
- - Trả về một khóa ngẫu nhiên từ keyspace
- - Đổi tên khóa
- - Rename a key, only if the new key does not exist
- - Determine the type stored at key
- - Sort the elements in a list, set or sorted set
- - Get the time to live for a key
- - Create a key using the provided serialized value, previously obtained with
get
Description. Get the value related to the specified key
Parameterskey
Return valueString or Bool. If key didn't exist,
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 is returned. Otherwise, the value related to this key is returnedví dụ# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
2set
Description. Set the string value in argument as value of the key. If you're using Redis >= 2. 6. 12, you can pass extended options as explained below
ParametersKey
Value
Timeout or Options Array [optional]. If you pass an integer, phpredis will redirect to SETEX, and will try to use Redis >= 2. 6. 12 extended options if you pass an array with valid values
Bool
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 if the command is successfulví dụ# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
3setEx, pSetEx
Description. Set the string value in argument as value of the key, with a time to live. PSETEX uses a TTL in milliseconds
ParametersKey TTL Value
Return valueBool
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 if the command is successfulví dụ# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
4setNx
Sự miêu tả. Set the string value in argument as value of the key if the key doesn't already exist in the database
Parameterskey value
Return valueBool
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 in case of success, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of failureví dụ# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
5del, delete, unlink
Description. Remove specified keys
ParametersAn array of keys, or an undefined number of parameters, each a key. key1 key2 key3 . keyN
Note. If you are connecting to Redis server >= 4. 0. 0 you can remove a key with the
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
63 method in the exact same way you would use # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
64. The Redis unlink command is non-blocking and will perform the actual deletion asynchronouslyReturn valueLong Number of keys deleted
ví dụ# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
6Note.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
91 is an alias for # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
64 and will be removed in future versions of phpredisexists
Description. Verify if the specified key exists
Parameterskey
Return valuelong. The number of keys tested that do exist
ví dụ# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
7Note. This function took a single argument and returned TRUE or FALSE in phpredis versions < 4. 0. 0
incr, incrBy
Description. Increment the number stored at key by one. If the second argument is filled, it will be used as the integer value of the increment
Parameterskey
value. value that will be added to key [only for incrBy]
INT the new value
ví dụ# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
8incrByFloat
Description. Increment the key with floating point precision
Parameterskey
value. [float] value that will be added to the key
FLOAT the new value
ví dụ# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
9decr, decrBy
Description. Decrement the number stored at key by one. If the second argument is filled, it will be used as the integer value of the decrement
Parameterskey
value. value that will be subtracted to key [only for decrBy]
INT the new value
ví dụ$redis = new Redis[];0
mGet, getMultiple
Description. Get the values of all the specified keys. If one or more keys don't exist, the array will contain
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 at the position of the keyParametersArray. Array containing the list of the keys
Return valueArray. Array containing the values related to keys in argument
ví dụ$redis = new Redis[];1
Note.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
94 is an alias for # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
95 and will be removed in future versions of phpredisgetSet
Description. Sets a value and returns the previous entry at that key
ParametersKey. key
STRING. value
Return valueA string, the previous value located at this key
Example$redis = new Redis[];2
randomKey
Description. Returns a random key
ParametersNone
Return valueSTRING. an existing key in redis
Example$redis = new Redis[];3
move
Description. Moves a key to a different database
ParametersKey. chìa khóa, chìa khóa để di chuyển
INTEGER. dbindex, the database number to move the key to
Return valueBOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 in case of success, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of failureExample$redis = new Redis[];4
rename, renameKey
Description. Renames a key
ParametersSTRING. srckey, the key to rename
STRING. dstkey, the new name for the key
Return valueBOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 in case of success, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of failureExample$redis = new Redis[];5
Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
00 is an alias for # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
01 and will be removed in future versions of phpredisrenameNx
Sự miêu tả. Tương tự như đổi tên, nhưng sẽ không thay thế khóa nếu đích đã tồn tại. Đây là hành vi tương tự như setNx
hết hạn, hết hạn
Sự miêu tả. Đặt thời gian hết hạn cho một khóa trong giây hoặc mili giây
Prototype$redis = new Redis[];6Return value
BOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 nếu thời hạn đã được đặt và # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 nếu không thành công hoặc nếu thời hạn không được đặt. Bạn có thể phân biệt giữa lỗi và thời hạn không được đặt bằng cách kiểm tra # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
04Example$redis = new Redis[];7
Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
05 is an alias for # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
06 and will be removed in future versions of phpredisexpireAt, pexpireAt
Description. Seta specific timestamp for a key to expire in seconds or milliseconds
Prototype$redis = new Redis[];8Return value
BOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 if an expiration was set and # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 if one was not set or in the event on an error. You can detect an actual error by checking # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
04Example$redis = new Redis[];9
keys, getKeys
Description. Returns the keys that match a certain pattern
ParametersSTRING. pattern, using '*' as a wildcard
Return valueArray of STRING. The keys that match a certain pattern
Example$redis = new Redis[[ 'host' => '127.0.0.1', 'port' => 6379, 'connectTimeout' => 2.5, 'auth' => ['phpredis', 'phpredis'], 'ssl' => ['verify_peer' => false], 'backoff' => [ 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, 'base' => 500, 'cap' => 750, ], ]];0
Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
10 is an alias for # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
11 and will be removed in future versions of phpredisscan
Description. Scan the keyspace for keys
ParametersLONG [reference]. Iterator, initialized to NULL STRING, Optional. Pattern to match LONG, Optional. Count of keys per iteration [only a suggestion to Redis]
Return valueArray, boolean. This function will return an array of keys or FALSE if Redis returned zero keys
Note. SCAN is a "directed node" command in
Example$redis = new Redis[[ 'host' => '127.0.0.1', 'port' => 6379, 'connectTimeout' => 2.5, 'auth' => ['phpredis', 'phpredis'], 'ssl' => ['verify_peer' => false], 'backoff' => [ 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, 'base' => 500, 'cap' => 750, ], ]];1
mục tiêu
Description. Describes the object pointed to by a key
ParametersThe information to retrieve [string] and the key [string]. Info can be one of the following
- "encoding"
- "refcount"
- "idletime"
STRING for "encoding", LONG for "refcount" and "idletime",
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 if the key doesn't existExample$redis = new Redis[[ 'host' => '127.0.0.1', 'port' => 6379, 'connectTimeout' => 2.5, 'auth' => ['phpredis', 'phpredis'], 'ssl' => ['verify_peer' => false], 'backoff' => [ 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, 'base' => 500, 'cap' => 750, ], ]];2
type
Description. Returns the type of data pointed by a given key
ParametersKey. key
Return valueDepending on the type of the data pointed by the key, this method will return the following value
string. Redis. REDIS_STRING
set. Redis. REDIS_SET
list. Redis. REDIS_LIST
zset. Redis. REDIS_ZSET
hash. Redis. REDIS_HASH
other. Redis. REDIS_NOT_FOUND
$redis = new Redis[[ 'host' => '127.0.0.1', 'port' => 6379, 'connectTimeout' => 2.5, 'auth' => ['phpredis', 'phpredis'], 'ssl' => ['verify_peer' => false], 'backoff' => [ 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, 'base' => 500, 'cap' => 750, ], ]];3
append
Description. Append specified string to the string stored in specified key
ParametersKey Value
Return valueINTEGER. Size of the value after the append
Example$redis = new Redis[[ 'host' => '127.0.0.1', 'port' => 6379, 'connectTimeout' => 2.5, 'auth' => ['phpredis', 'phpredis'], 'ssl' => ['verify_peer' => false], 'backoff' => [ 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, 'base' => 500, 'cap' => 750, ], ]];4
getRange
Description. Return a substring of a larger string
Parameterskey
start
end
STRING. the substring
Example$redis = new Redis[[ 'host' => '127.0.0.1', 'port' => 6379, 'connectTimeout' => 2.5, 'auth' => ['phpredis', 'phpredis'], 'ssl' => ['verify_peer' => false], 'backoff' => [ 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, 'base' => 500, 'cap' => 750, ], ]];5
Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
13 is an alias for # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
14 and will be removed in future versions of phpredissetRange
Description. Changes a substring of a larger string
Parametersgiá trị bù khóa
Return valueSTRING. the length of the string after it was modified
Example$redis = new Redis[[ 'host' => '127.0.0.1', 'port' => 6379, 'connectTimeout' => 2.5, 'auth' => ['phpredis', 'phpredis'], 'ssl' => ['verify_peer' => false], 'backoff' => [ 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, 'base' => 500, 'cap' => 750, ], ]];6
strLen
Description. Get the length of a string value
Parameterskey
Return valueINTEGER
Example$redis = new Redis[[ 'host' => '127.0.0.1', 'port' => 6379, 'connectTimeout' => 2.5, 'auth' => ['phpredis', 'phpredis'], 'ssl' => ['verify_peer' => false], 'backoff' => [ 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, 'base' => 500, 'cap' => 750, ], ]];7
getBit
Description. Return a single bit out of a larger string
Parameterskey
offset
LONG. the bit value [0 or 1]
Example$redis = new Redis[[ 'host' => '127.0.0.1', 'port' => 6379, 'connectTimeout' => 2.5, 'auth' => ['phpredis', 'phpredis'], 'ssl' => ['verify_peer' => false], 'backoff' => [ 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, 'base' => 500, 'cap' => 750, ], ]];8
setBit
Description. Changes a single bit of a string
Parameterskey
offset
value. bool or int [1 or 0]
LONG. 0 or 1, the value of the bit before it was set
Example$redis = new Redis[[ 'host' => '127.0.0.1', 'port' => 6379, 'connectTimeout' => 2.5, 'auth' => ['phpredis', 'phpredis'], 'ssl' => ['verify_peer' => false], 'backoff' => [ 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, 'base' => 500, 'cap' => 750, ], ]];9
bitOp
Description. Bitwise operation on multiple keys
Parametersoperation. either "AND", "OR", "NOT", "XOR"
ret_key. return key
key1
key2
LONG. The size of the string stored in the destination key
bitCount
Description. Count bits in a string
Parameterskey
Return valueLONG. The number of bits set to 1 in the value behind the input key
sort
Description. Sort the elements in a list, set or sorted set
ParametersKey. key Options. [key => value, . ] - optional, with the following keys and values
Redis::REDIS_STRING - String
Redis::REDIS_SET - Set
Redis::REDIS_LIST - List
Redis::REDIS_ZSET - Sorted set
Redis::REDIS_HASH - Hash
Redis::REDIS_NOT_FOUND - Not found / other
0Return valueAn array of values, or a number corresponding to the number of elements stored if that was used
ExampleRedis::REDIS_STRING - String
Redis::REDIS_SET - Set
Redis::REDIS_LIST - List
Redis::REDIS_ZSET - Sorted set
Redis::REDIS_HASH - Hash
Redis::REDIS_NOT_FOUND - Not found / other
1ttl, pttl
Description. Returns the time to live left for a given key in seconds [ttl], or milliseconds [pttl]
ParametersKey. key
Return valueLONG. The time to live in seconds. If the key has no ttl,
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
15 will be returned, and # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
16 if the key doesn't existExampleRedis::REDIS_STRING - String
Redis::REDIS_SET - Set
Redis::REDIS_LIST - List
Redis::REDIS_ZSET - Sorted set
Redis::REDIS_HASH - Hash
Redis::REDIS_NOT_FOUND - Not found / other
2persist
Description. Remove the expiration timer from a key
ParametersKey. key
Return valueBOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 if a timeout was removed, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 if the key didn’t exist or didn’t have an expiration timerExampleRedis::REDIS_STRING - String
Redis::REDIS_SET - Set
Redis::REDIS_LIST - List
Redis::REDIS_ZSET - Sorted set
Redis::REDIS_HASH - Hash
Redis::REDIS_NOT_FOUND - Not found / other
3mSet, mSetNx
Sự miêu tả. Sets multiple key-value pairs in one atomic command. MSETNX only returns TRUE if all the keys were set [see SETNX]
ParametersPairs. [key => value, . ]
Return valueBool
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 in case of success, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of failureExampleRedis::REDIS_STRING - String
Redis::REDIS_SET - Set
Redis::REDIS_LIST - List
Redis::REDIS_ZSET - Sorted set
Redis::REDIS_HASH - Hash
Redis::REDIS_NOT_FOUND - Not found / other
4Output
Redis::REDIS_STRING - String
Redis::REDIS_SET - Set
Redis::REDIS_LIST - List
Redis::REDIS_ZSET - Sorted set
Redis::REDIS_HASH - Hash
Redis::REDIS_NOT_FOUND - Not found / other
5dump
Description. Dump a key out of a redis database, the value of which can later be passed into redis using the RESTORE command. The data that comes out of DUMP is a binary representation of the key as Redis stores it
Parameterskey string
Return valueThe Redis encoded value of the key, or FALSE if the key doesn't exist
ví dụRedis::REDIS_STRING - String
Redis::REDIS_SET - Set
Redis::REDIS_LIST - List
Redis::REDIS_ZSET - Sorted set
Redis::REDIS_HASH - Hash
Redis::REDIS_NOT_FOUND - Not found / other
6restore
Description. Restore a key from the result of a DUMP operation
Parameterskey string. The key name
ttl integer. How long the key should live [if zero, no expire will be set on the key]
value string [binary]. The Redis encoded key value [from DUMP]
Redis::REDIS_STRING - String
Redis::REDIS_SET - Set
Redis::REDIS_LIST - List
Redis::REDIS_ZSET - Sorted set
Redis::REDIS_HASH - Hash
Redis::REDIS_NOT_FOUND - Not found / other
7migrate
Description. Migrates a key to a different Redis instance
Note. Redis introduced migrating multiple keys in 3. 0. 6, so you must have at least that version in order to call
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
21 with an array of keysParametershost string. The destination host
port integer. The TCP port to connect to
key[s] string or array
destination-db integer. The target DB
timeout integer. The maximum amount of time given to this transfer
copy boolean, optional. Should we send the COPY flag to redis
replace boolean, optional. Should we send the REPLACE flag to redis
Redis::REDIS_STRING - String
Redis::REDIS_SET - Set
Redis::REDIS_LIST - List
Redis::REDIS_ZSET - Sorted set
Redis::REDIS_HASH - Hash
Redis::REDIS_NOT_FOUND - Not found / other
8Hashes
- - Delete one or more hash fields
- - Determine if a hash field exists
- - Get the value of a hash field
- - Get all the fields and values in a hash
- - Increment the integer value of a hash field by the given number
- - Increment the float value of a hash field by the given amount
- - Get all the fields in a hash
- - Get the number of fields in a hash
- - Get the values of all the given hash fields
- - Set multiple hash fields to multiple values
- - Set the string value of a hash field
- - Set the value of a hash field, only if the field does not exist
- - Get all the values in a hash
- - Scan a hash key for members
- - Get the string length of the value associated with field in the hash
hSet
Description. Adds a value to the hash stored at key
Parameterskey
hashKey
value
LONG
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
22 if value didn't exist and was added successfully, # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
23 if the value was already present and was replaced, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 if there was an errorExampleRedis::REDIS_STRING - String
Redis::REDIS_SET - Set
Redis::REDIS_LIST - List
Redis::REDIS_ZSET - Sorted set
Redis::REDIS_HASH - Hash
Redis::REDIS_NOT_FOUND - Not found / other
9hSetNx
Description. Adds a value to the hash stored at key only if this field isn't already in the hash
Return valueBOOL
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 if the field was set, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 if it was already presentExample$redis->connect['127.0.0.1', 6379]; $redis->connect['127.0.0.1']; // port 6379 by default $redis->connect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->connect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->connect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout. $redis->connect['/tmp/redis.sock']; // unix domain socket. $redis->connect['127.0.0.1', 6379, 1, '', 100]; // 1 sec timeout, 100ms delay between reconnection attempts. $redis->connect['/tmp/redis.sock', 0, 1.5, NULL, 0, 1.5]; // Unix socket with 1.5s timeouts [connect and read] /* With PhpRedis >= 5.3.0 you can specify authentication and stream information on connect */ $redis->connect['127.0.0.1', 6379, 1, '', 0, 0, ['auth' => ['phpredis', 'phpredis']]];0
hGet
Description. Gets a value from the hash stored at key. If the hash table doesn't exist, or the key doesn't exist,
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 is returnedParameterskey
hashKey
STRING The value, if the command executed successfully
BOOL
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of failurehLen
Description. Returns the length of a hash, in number of items
Parameterskey
Return valueLONG the number of items in a hash,
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 if the key doesn't exist or isn't a hashExample$redis->connect['127.0.0.1', 6379]; $redis->connect['127.0.0.1']; // port 6379 by default $redis->connect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->connect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->connect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout. $redis->connect['/tmp/redis.sock']; // unix domain socket. $redis->connect['127.0.0.1', 6379, 1, '', 100]; // 1 sec timeout, 100ms delay between reconnection attempts. $redis->connect['/tmp/redis.sock', 0, 1.5, NULL, 0, 1.5]; // Unix socket with 1.5s timeouts [connect and read] /* With PhpRedis >= 5.3.0 you can specify authentication and stream information on connect */ $redis->connect['127.0.0.1', 6379, 1, '', 0, 0, ['auth' => ['phpredis', 'phpredis']]];1
hDel
Description. Removes a value from the hash stored at key. If the hash table doesn't exist, or the key doesn't exist,
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 is returnedParameterskey
hashKey1
hashKey2
...
LONG số lượng khóa đã xóa, 0 nếu khóa không tồn tại,
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 nếu khóa không phải là hàm bămhKeys
Sự miêu tả. Trả về các khóa ở dạng băm, dưới dạng một chuỗi các chuỗi
ParametersKey. key
Return valueMột mảng các phần tử, các khóa của hàm băm. Điều này hoạt động giống như mảng_keys[] của PHP
Example$redis->connect['127.0.0.1', 6379]; $redis->connect['127.0.0.1']; // port 6379 by default $redis->connect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->connect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->connect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout. $redis->connect['/tmp/redis.sock']; // unix domain socket. $redis->connect['127.0.0.1', 6379, 1, '', 100]; // 1 sec timeout, 100ms delay between reconnection attempts. $redis->connect['/tmp/redis.sock', 0, 1.5, NULL, 0, 1.5]; // Unix socket with 1.5s timeouts [connect and read] /* With PhpRedis >= 5.3.0 you can specify authentication and stream information on connect */ $redis->connect['127.0.0.1', 6379, 1, '', 0, 0, ['auth' => ['phpredis', 'phpredis']]];2
Output
$redis->connect['127.0.0.1', 6379]; $redis->connect['127.0.0.1']; // port 6379 by default $redis->connect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->connect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->connect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout. $redis->connect['/tmp/redis.sock']; // unix domain socket. $redis->connect['127.0.0.1', 6379, 1, '', 100]; // 1 sec timeout, 100ms delay between reconnection attempts. $redis->connect['/tmp/redis.sock', 0, 1.5, NULL, 0, 1.5]; // Unix socket with 1.5s timeouts [connect and read] /* With PhpRedis >= 5.3.0 you can specify authentication and stream information on connect */ $redis->connect['127.0.0.1', 6379, 1, '', 0, 0, ['auth' => ['phpredis', 'phpredis']]];3
The order is random and corresponds to redis' own internal representation of the set structure
hVals
Description. Returns the values in a hash, as an array of strings
ParametersKey. key
Return valueAn array of elements, the values of the hash. This works like PHP's array_values[]
Example$redis->connect['127.0.0.1', 6379]; $redis->connect['127.0.0.1']; // port 6379 by default $redis->connect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->connect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->connect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout. $redis->connect['/tmp/redis.sock']; // unix domain socket. $redis->connect['127.0.0.1', 6379, 1, '', 100]; // 1 sec timeout, 100ms delay between reconnection attempts. $redis->connect['/tmp/redis.sock', 0, 1.5, NULL, 0, 1.5]; // Unix socket with 1.5s timeouts [connect and read] /* With PhpRedis >= 5.3.0 you can specify authentication and stream information on connect */ $redis->connect['127.0.0.1', 6379, 1, '', 0, 0, ['auth' => ['phpredis', 'phpredis']]];4
Output
$redis->connect['127.0.0.1', 6379]; $redis->connect['127.0.0.1']; // port 6379 by default $redis->connect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->connect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->connect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout. $redis->connect['/tmp/redis.sock']; // unix domain socket. $redis->connect['127.0.0.1', 6379, 1, '', 100]; // 1 sec timeout, 100ms delay between reconnection attempts. $redis->connect['/tmp/redis.sock', 0, 1.5, NULL, 0, 1.5]; // Unix socket with 1.5s timeouts [connect and read] /* With PhpRedis >= 5.3.0 you can specify authentication and stream information on connect */ $redis->connect['127.0.0.1', 6379, 1, '', 0, 0, ['auth' => ['phpredis', 'phpredis']]];5
The order is random and corresponds to redis' own internal representation of the set structure
hGetAll
Description. Returns the whole hash, as an array of strings indexed by strings
ParametersKey. key
Return valueAn array of elements, the contents of the hash
Example$redis->connect['127.0.0.1', 6379]; $redis->connect['127.0.0.1']; // port 6379 by default $redis->connect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->connect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->connect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout. $redis->connect['/tmp/redis.sock']; // unix domain socket. $redis->connect['127.0.0.1', 6379, 1, '', 100]; // 1 sec timeout, 100ms delay between reconnection attempts. $redis->connect['/tmp/redis.sock', 0, 1.5, NULL, 0, 1.5]; // Unix socket with 1.5s timeouts [connect and read] /* With PhpRedis >= 5.3.0 you can specify authentication and stream information on connect */ $redis->connect['127.0.0.1', 6379, 1, '', 0, 0, ['auth' => ['phpredis', 'phpredis']]];6
Output
$redis->connect['127.0.0.1', 6379]; $redis->connect['127.0.0.1']; // port 6379 by default $redis->connect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->connect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->connect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout. $redis->connect['/tmp/redis.sock']; // unix domain socket. $redis->connect['127.0.0.1', 6379, 1, '', 100]; // 1 sec timeout, 100ms delay between reconnection attempts. $redis->connect['/tmp/redis.sock', 0, 1.5, NULL, 0, 1.5]; // Unix socket with 1.5s timeouts [connect and read] /* With PhpRedis >= 5.3.0 you can specify authentication and stream information on connect */ $redis->connect['127.0.0.1', 6379, 1, '', 0, 0, ['auth' => ['phpredis', 'phpredis']]];7
The order is random and corresponds to redis' own internal representation of the set structure
hExists
Description. Verify if the specified member exists in a key
Parameterskey
memberKey
BOOL. If the member exists in the hash table, return
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24, otherwise return # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23ví dụ$redis->connect['127.0.0.1', 6379]; $redis->connect['127.0.0.1']; // port 6379 by default $redis->connect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->connect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->connect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout. $redis->connect['/tmp/redis.sock']; // unix domain socket. $redis->connect['127.0.0.1', 6379, 1, '', 100]; // 1 sec timeout, 100ms delay between reconnection attempts. $redis->connect['/tmp/redis.sock', 0, 1.5, NULL, 0, 1.5]; // Unix socket with 1.5s timeouts [connect and read] /* With PhpRedis >= 5.3.0 you can specify authentication and stream information on connect */ $redis->connect['127.0.0.1', 6379, 1, '', 0, 0, ['auth' => ['phpredis', 'phpredis']]];8
hIncrBy
Description. Increments the value of a member from a hash by a given amount
Parameterskey
member
value. [integer] value that will be added to the member's value
LONG the new value
ví dụ$redis->connect['127.0.0.1', 6379]; $redis->connect['127.0.0.1']; // port 6379 by default $redis->connect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->connect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->connect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout. $redis->connect['/tmp/redis.sock']; // unix domain socket. $redis->connect['127.0.0.1', 6379, 1, '', 100]; // 1 sec timeout, 100ms delay between reconnection attempts. $redis->connect['/tmp/redis.sock', 0, 1.5, NULL, 0, 1.5]; // Unix socket with 1.5s timeouts [connect and read] /* With PhpRedis >= 5.3.0 you can specify authentication and stream information on connect */ $redis->connect['127.0.0.1', 6379, 1, '', 0, 0, ['auth' => ['phpredis', 'phpredis']]];9
hIncrByFloat
Description. Increments the value of a hash member by the provided float value
Parameterskey
member
value. [float] value that will be added to the member's value
FLOAT the new value
ví dụ$redis->pconnect['127.0.0.1', 6379]; $redis->pconnect['127.0.0.1']; // port 6379 by default - same connection like before. $redis->pconnect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->pconnect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->pconnect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout and would be another connection than the two before. $redis->pconnect['127.0.0.1', 6379, 2.5, 'x']; // x is sent as persistent_id and would be another connection than the three before. $redis->pconnect['/tmp/redis.sock']; // unix domain socket - would be another connection than the four before.0
hMSet
Description. Điền vào toàn bộ hàm băm. Non-string values are converted to string, using the standard
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
34 cast. NULL values are stored as empty stringsParameterskey
members. key → value array
BOOL
ví dụ$redis->pconnect['127.0.0.1', 6379]; $redis->pconnect['127.0.0.1']; // port 6379 by default - same connection like before. $redis->pconnect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->pconnect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->pconnect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout and would be another connection than the two before. $redis->pconnect['127.0.0.1', 6379, 2.5, 'x']; // x is sent as persistent_id and would be another connection than the three before. $redis->pconnect['/tmp/redis.sock']; // unix domain socket - would be another connection than the four before.1
hMGet
Description. Retrieve the values associated to the specified fields in the hash
Parameterskey
memberKeys Array
Array An array of elements, the values of the specified fields in the hash, with the hash keys as array keys
ví dụ$redis->pconnect['127.0.0.1', 6379]; $redis->pconnect['127.0.0.1']; // port 6379 by default - same connection like before. $redis->pconnect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->pconnect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->pconnect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout and would be another connection than the two before. $redis->pconnect['127.0.0.1', 6379, 2.5, 'x']; // x is sent as persistent_id and would be another connection than the three before. $redis->pconnect['/tmp/redis.sock']; // unix domain socket - would be another connection than the four before.2
hScan
Description. Scan a HASH value for members, with an optional pattern and count
Parameterskey. String
iterator. Long [reference]
pattern. Optional pattern to match against
count. How many keys to return in a go [only a suggestion to Redis]
Array An array of members that match our pattern
ví dụ$redis->pconnect['127.0.0.1', 6379]; $redis->pconnect['127.0.0.1']; // port 6379 by default - same connection like before. $redis->pconnect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->pconnect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->pconnect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout and would be another connection than the two before. $redis->pconnect['127.0.0.1', 6379, 2.5, 'x']; // x is sent as persistent_id and would be another connection than the three before. $redis->pconnect['/tmp/redis.sock']; // unix domain socket - would be another connection than the four before.3
hStrLen
Description. Get the string length of the value associated with field in the hash stored at key
Parameterskey. String
field. String
LONG the string length of the value associated with field, or zero when field is not present in the hash or key does not exist at all
Lists
- - Remove and get the first/last element in a list
- - Pop a value from a list, push it to another list and return it
- - Get an element from a list by its index
- - Insert an element before or after another element in a list
- - Get the length/size of a list
- - Remove and get the first element in a list
- - Prepend one or multiple values to a list
- - Prepend a value to a list, only if the list exists
- - Get a range of elements from a list
- - Remove elements from a list
- - Set the value of an element in a list by its index
- - Trim a list to the specified range
- - Remove and get the last element in a list
- - Remove the last element in a list, append it to another list and return it [redis >= 1. 1]
- - Append one or multiple values to a list
- - Append a value to a list, only if the list exists
blPop, brPop
Description. Là một nguyên thủy chặn lPop[rPop]. If at least one of the lists contains at least one element, the element will be popped from the head of the list and returned to the caller. If all the list identified by the keys passed in arguments are empty, blPop will block during the specified timeout until an element is pushed to one of those lists. This element will be popped
ParametersARRAY Array containing the keys of the lists
INTEGER Timeout
Or
STRING Key1
STRING Key2
STRING Key3
...
STRING Keyn
INTEGER Timeout
ARRAY ['listName', 'element']
Example$redis->pconnect['127.0.0.1', 6379]; $redis->pconnect['127.0.0.1']; // port 6379 by default - same connection like before. $redis->pconnect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->pconnect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->pconnect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout and would be another connection than the two before. $redis->pconnect['127.0.0.1', 6379, 2.5, 'x']; // x is sent as persistent_id and would be another connection than the three before. $redis->pconnect['/tmp/redis.sock']; // unix domain socket - would be another connection than the four before.4
bRPopLPush
Description. A blocking version of
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
35, with an integral timeout in the third parameterParametersKey. srckey
Key. dstkey
Long. hết giờ
STRING Phần tử đã được di chuyển trong trường hợp thành công,
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 trong trường hợp hết thời gian chờlChỉ mục, lNhận
Sự miêu tả. Trả về phần tử đã chỉ định của danh sách được lưu trữ tại khóa đã chỉ định
0 phần tử đầu tiên, 1 phần thứ hai
-1 phần tử cuối cùng, -2 phần tử áp chót
Return
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of a bad index or a key that doesn't point to a listParameterskey
index
String the element at this index
Bool
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 if the key identifies a non-string data type, or no value corresponds to this index in the list # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
39Example$redis->pconnect['127.0.0.1', 6379]; $redis->pconnect['127.0.0.1']; // port 6379 by default - same connection like before. $redis->pconnect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->pconnect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->pconnect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout and would be another connection than the two before. $redis->pconnect['127.0.0.1', 6379, 2.5, 'x']; // x is sent as persistent_id and would be another connection than the three before. $redis->pconnect['/tmp/redis.sock']; // unix domain socket - would be another connection than the four before.5
Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
40 is an alias for # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
41 and will be removed in future versions of phpredislInsert
Description. Insert value in the list before or after the pivot value
The parameter options specify the position of the insert [before or after]. If the list didn't exists, or the pivot didn't exists, the value is not inserted
Parameterskey
position Redis. BEFORE . Redis. AFTER
pivot
value
The number of the elements in the list, -1 if the pivot didn't exists
Example$redis->pconnect['127.0.0.1', 6379]; $redis->pconnect['127.0.0.1']; // port 6379 by default - same connection like before. $redis->pconnect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->pconnect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->pconnect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout and would be another connection than the two before. $redis->pconnect['127.0.0.1', 6379, 2.5, 'x']; // x is sent as persistent_id and would be another connection than the three before. $redis->pconnect['/tmp/redis.sock']; // unix domain socket - would be another connection than the four before.6
lPop
Description. Return and remove the first element of the list
Parameterskey
Return valueSTRING if command executed successfully
BOOL
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of failure [empty list]Example$redis->pconnect['127.0.0.1', 6379]; $redis->pconnect['127.0.0.1']; // port 6379 by default - same connection like before. $redis->pconnect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->pconnect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->pconnect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout and would be another connection than the two before. $redis->pconnect['127.0.0.1', 6379, 2.5, 'x']; // x is sent as persistent_id and would be another connection than the three before. $redis->pconnect['/tmp/redis.sock']; // unix domain socket - would be another connection than the four before.7
lPush
Description. Adds one or more values to the head of a LIST. Tạo danh sách nếu khóa không tồn tại. If the key exists and is not a list,
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 is returnedPrototype$redis->pconnect['127.0.0.1', 6379]; $redis->pconnect['127.0.0.1']; // port 6379 by default - same connection like before. $redis->pconnect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->pconnect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->pconnect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout and would be another connection than the two before. $redis->pconnect['127.0.0.1', 6379, 2.5, 'x']; // x is sent as persistent_id and would be another connection than the three before. $redis->pconnect['/tmp/redis.sock']; // unix domain socket - would be another connection than the four before.8Return value
LONG The new length of the list in case of success,
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of Failureví dụ$redis->pconnect['127.0.0.1', 6379]; $redis->pconnect['127.0.0.1']; // port 6379 by default - same connection like before. $redis->pconnect['tls://127.0.0.1', 6379]; // enable transport level security. $redis->pconnect['tls://127.0.0.1']; // enable transport level security, port 6379 by default. $redis->pconnect['127.0.0.1', 6379, 2.5]; // 2.5 sec timeout and would be another connection than the two before. $redis->pconnect['127.0.0.1', 6379, 2.5, 'x']; // x is sent as persistent_id and would be another connection than the three before. $redis->pconnect['/tmp/redis.sock']; // unix domain socket - would be another connection than the four before.9
lPushx
Description. Adds the string value to the head [left] of the list if the list exists
Parameterskey
value String, value to push in key
LONG The new length of the list in case of success,
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of Failureví dụ/* Authenticate with the password 'foobared' */ $redis->auth['foobared']; /* Authenticate with the username 'phpredis', and password 'haxx00r' */ $redis->auth[['phpredis', 'haxx00r']]; /* Authenticate with the password 'foobared' */ $redis->auth[['foobared']]; /* You can also use an associative array specifying user and pass */ $redis->auth[['user' => 'phpredis', 'pass' => 'phpredis']]; $redis->auth[['pass' => 'phpredis']];0
lRange, lGetRange
Description. Returns the specified elements of the list stored at the specified key in the range [start, end]. start and stop are interpreted as indices
0 phần tử đầu tiên, 1 phần thứ hai
-1 phần tử cuối cùng, -2 phần tử áp chót
key
start
end
Array containing the values in specified range
Example/* Authenticate with the password 'foobared' */ $redis->auth['foobared']; /* Authenticate with the username 'phpredis', and password 'haxx00r' */ $redis->auth[['phpredis', 'haxx00r']]; /* Authenticate with the password 'foobared' */ $redis->auth[['foobared']]; /* You can also use an associative array specifying user and pass */ $redis->auth[['user' => 'phpredis', 'pass' => 'phpredis']]; $redis->auth[['pass' => 'phpredis']];1
Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
46 is an alias for # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
47 and will be removed in future versions of phpredislRem, lRemove
Description. Removes the first
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
48 occurrences of the value element from the list. If count is zero, all the matching elements are removed. If count is negative, elements are removed from tail to headNote. The argument order is not the same as in the Redis documentation. This difference is kept for compatibility reasons
key
value
count
LONG the number of elements to remove
BOOL
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 if the value identified by key is not a listExample/* Authenticate with the password 'foobared' */ $redis->auth['foobared']; /* Authenticate with the username 'phpredis', and password 'haxx00r' */ $redis->auth[['phpredis', 'haxx00r']]; /* Authenticate with the password 'foobared' */ $redis->auth[['foobared']]; /* You can also use an associative array specifying user and pass */ $redis->auth[['user' => 'phpredis', 'pass' => 'phpredis']]; $redis->auth[['pass' => 'phpredis']];2
Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
50 is an alias for # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
51 and will be removed in future versions of phpredislSet
Description. Set the list at index with the new value
Parameterskey
index
value
BOOL
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 if the new value was set. # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 if the index is out of range, or data type identified by key is not a listExample/* Authenticate with the password 'foobared' */ $redis->auth['foobared']; /* Authenticate with the username 'phpredis', and password 'haxx00r' */ $redis->auth[['phpredis', 'haxx00r']]; /* Authenticate with the password 'foobared' */ $redis->auth[['foobared']]; /* You can also use an associative array specifying user and pass */ $redis->auth[['user' => 'phpredis', 'pass' => 'phpredis']]; $redis->auth[['pass' => 'phpredis']];3
lTrim, listTrim
Description. Trims an existing list so that it will contain only a specified range of elements
Parameterskey
start
stop
Array
Bool return
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 if the key identify a non-list valueExample/* Authenticate with the password 'foobared' */ $redis->auth['foobared']; /* Authenticate with the username 'phpredis', and password 'haxx00r' */ $redis->auth[['phpredis', 'haxx00r']]; /* Authenticate with the password 'foobared' */ $redis->auth[['foobared']]; /* You can also use an associative array specifying user and pass */ $redis->auth[['user' => 'phpredis', 'pass' => 'phpredis']]; $redis->auth[['pass' => 'phpredis']];4
Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
55 is an alias for # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
56 and will be removed in future versions of phpredisrPop
Description. Returns and removes the last element of the list
Parameterskey
Return valueSTRING if command executed successfully
BOOL
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of failure [empty list]Example/* Authenticate with the password 'foobared' */ $redis->auth['foobared']; /* Authenticate with the username 'phpredis', and password 'haxx00r' */ $redis->auth[['phpredis', 'haxx00r']]; /* Authenticate with the password 'foobared' */ $redis->auth[['foobared']]; /* You can also use an associative array specifying user and pass */ $redis->auth[['user' => 'phpredis', 'pass' => 'phpredis']]; $redis->auth[['pass' => 'phpredis']];5
rPopLPush
Description. Pops a value from the tail of a list, and pushes it to the front of another list. Also return this value. [redis >= 1. 1]
ParametersKey. srckey
Key. dstkey
STRING The element that was moved in case of success,
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of failureExample/* Authenticate with the password 'foobared' */ $redis->auth['foobared']; /* Authenticate with the username 'phpredis', and password 'haxx00r' */ $redis->auth[['phpredis', 'haxx00r']]; /* Authenticate with the password 'foobared' */ $redis->auth[['foobared']]; /* You can also use an associative array specifying user and pass */ $redis->auth[['user' => 'phpredis', 'pass' => 'phpredis']]; $redis->auth[['pass' => 'phpredis']];6
Output
/* Authenticate with the password 'foobared' */ $redis->auth['foobared']; /* Authenticate with the username 'phpredis', and password 'haxx00r' */ $redis->auth[['phpredis', 'haxx00r']]; /* Authenticate with the password 'foobared' */ $redis->auth[['foobared']]; /* You can also use an associative array specifying user and pass */ $redis->auth[['user' => 'phpredis', 'pass' => 'phpredis']]; $redis->auth[['pass' => 'phpredis']];7
rPush
Description. Adds one or more entries to the tail of a LIST. Redis will create the list if it doesn't exist
Prototype/* Authenticate with the password 'foobared' */ $redis->auth['foobared']; /* Authenticate with the username 'phpredis', and password 'haxx00r' */ $redis->auth[['phpredis', 'haxx00r']]; /* Authenticate with the password 'foobared' */ $redis->auth[['foobared']]; /* You can also use an associative array specifying user and pass */ $redis->auth[['user' => 'phpredis', 'pass' => 'phpredis']]; $redis->auth[['pass' => 'phpredis']];8Return value
LONG The new length of the list in case of success,
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of Failureví dụ/* Authenticate with the password 'foobared' */ $redis->auth['foobared']; /* Authenticate with the username 'phpredis', and password 'haxx00r' */ $redis->auth[['phpredis', 'haxx00r']]; /* Authenticate with the password 'foobared' */ $redis->auth[['foobared']]; /* You can also use an associative array specifying user and pass */ $redis->auth[['user' => 'phpredis', 'pass' => 'phpredis']]; $redis->auth[['pass' => 'phpredis']];9
rPushX
Sự miêu tả. Adds the string value to the tail [right] of the list if the list exists.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of FailureParameterskey
value String, value to push in key
LONG The new length of the list in case of success,
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of Failureví dụ; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
00lLen, lSize
Description. Returns the size of a list identified by Key
If the list didn't exist or is empty, the command returns 0. If the data type identified by Key is not a list, the command return
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23ParametersKey
Return valueLONG The size of the list identified by Key exists
BOOL
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 if the data type identified by Key is not listExample; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
01Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
64 is an alias for # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
65 and will be removed in future versions of phpredisSets
- - Thêm một hoặc nhiều thành viên vào một bộ
- - Get the number of members in a set
- - Subtract multiple sets
- - Subtract multiple sets and store the resulting set in a key
- - Intersect multiple sets
- - Intersect multiple sets and store the resulting set in a key
- - Determine if a given value is a member of a set
- - Get all the members in a set
- - Move a member from one set to another
- - Remove and return one or more members of a set at random
- - Get one or multiple random members from a set
- - Remove one or more members from a set
- - Add multiple sets
- - Add multiple sets and store the resulting set in a key
- - Scan a set for members
sAdd
Description. Adds a value to the set value stored at key
Parameterskey
value
LONG the number of elements added to the set
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
02sCard, sSize
Description. Returns the cardinality of the set identified by key
Parameterskey
Return valueLONG the cardinality of the set identified by key, 0 if the set doesn't exist
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
03Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
66 is an alias for # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
67 and will be removed in future versions of phpredissDiff
Description. Performs the difference between N sets and returns it
ParametersKeys. key1, key2, . , keyN. Any number of keys corresponding to sets in redis
Return valueArray of strings. The difference of the first set will all the others
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
04Return value. all elements of s0 that are neither in s1 nor in s2
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
05sDiffStore
Description. Thực hiện hành động tương tự như sDiff, nhưng lưu trữ kết quả trong khóa đầu tiên
ParametersKey. dstkey, the key to store the diff into
Keys. key1, key2, . , keyN. Any number of keys corresponding to sets in redis
Return valueINTEGER. The cardinality of the resulting set, or
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of a missing keyExample; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
06Return value. the number of elements of s0 that are neither in s1 nor in s2
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
07sInter
Description. Returns the members of a set resulting from the intersection of all the sets held at the specified keys
If just a single key is specified, then this command produces the members of this set. If one of the keys is missing,
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 is returnedParameterskey1, key2, keyN. keys identifying the different sets on which we will apply the intersection
Return valueArray, contain the result of the intersection between those keys. If the intersection between the different sets is empty, the return value will be empty array
ví dụ; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
08Output
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
09sInterStore
Description. Performs a sInter command and stores the result in a new set
ParametersKey. dstkey, the key to store the diff into
Keys. key1, key2. keyN. key1. keyN are intersected as in sInter
Return valueINTEGER. The cardinality of the resulting set, or
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of a missing keyExample; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
10Output
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
11sIsMember, sContains
Description. Checks if
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
71 is a member of the set stored at the key # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
72Parameterskey
value
BOOL
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 if # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
71 is a member of the set at key # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
72, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 otherwiseExample; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
12Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
77 is an alias for # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
78 and will be removed in future versions of phpredissMembers, sGetMembers
Description. Returns the contents of a set
ParametersKey. key
Return valueAn array of elements, the contents of the set
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
13Output
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
14The order is random and corresponds to redis' own internal representation of the set structure
Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
79 is an alias for # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
80 and will be removed in future versions of phpredissMove
Description. Moves the specified member from the set at srcKey to the set at dstKey
ParameterssrcKey
dstKey
member
BOOL If the operation is successful, return
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24. If the srcKey and/or dstKey didn't exist, and/or the member didn't exist in srcKey, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 is returnedExample; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
15sPop
Description. Removes and returns a random element from the set value at Key
Parameterskey
đếm. Integer, optional
String "popped" value
Bool
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 if set identified by key is empty or doesn't existReturn value [with count argument]Array. Member[s] returned or an empty array if the set doesn't exist
Bool.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 on error if the key is not a setExample; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
16sRandMember
Description. Returns a random element from the set value at Key, without removing it
Parameterskey
count [Integer, optional]
If no count is provided, a random String value from the set will be returned. If a count is provided, an array of values from the set will be returned. Read about the different ways to use the count here. SRANDMEMBER Bool
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 if set identified by key is empty or doesn't existExample; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
17sRem, sRemove
Description. Removes the specified member from the set value stored at key
Parameterskey
member
LONG Số phần tử bị xóa khỏi tập hợp
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
18Ghi chú.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
86 is an alias for # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
87 and will be removed in future versions of phpredissUnion
Description. Performs the union between N sets and returns it
ParametersKeys. key1, key2, . , keyN. Any number of keys corresponding to sets in redis
Return valueArray of strings. The union of all these sets
Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
88 can also take a single array with keys [see example below]Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
19Return value. all elements that are either in s0 or in s1 or in s2
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
20sUnionStore
Description. Performs the same action as sUnion, but stores the result in the first key
ParametersKey. dstkey, the key to store the diff into
Keys. key1, key2, . , keyN. Any number of keys corresponding to sets in redis
Return valueINTEGER. The cardinality of the resulting set, or
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 in case of a missing keyExample; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
21Return value. the number of elements that are either in s0 or in s1 or in s2
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
22sScan
Description. Scan a set for members
ParametersKey. The set to search
iterator. LONG [reference] to the iterator as we go
pattern. String, optional pattern to match against
count. Số lượng thành viên trả lại cùng một lúc [Redis có thể trả lại một số tiền khác]
Array, boolean. PHPRedis will return an array of keys or FALSE when we're done iterating
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
23Sorted sets
- - Block until Redis can pop the highest or lowest scoring member from one or more ZSETs
- - Add one or more members to a sorted set or update its score if it already exists
- - Get the number of members in a sorted set
- - Count the members in a sorted set with scores within the given values
- - Increment the score of a member in a sorted set
- - Intersect multiple sorted sets and store the resulting sorted set in a new key
- - Redis can pop the highest or lowest scoring member from one a ZSET
- - Return a range of members in a sorted set, by index
- - Return a range of members in a sorted set, by score
- - Return a lexicographical range from members that share the same score
- - Determine the index of a member in a sorted set
- - Remove one or more members from a sorted set
- - Remove all members in a sorted set within the given indexes
- - Remove all members in a sorted set within the given scores
- - Return a range of members in a sorted set, by index, with scores ordered from high to low
- - Get the score associated with the given member in a sorted set
- - Add multiple sorted sets and store the resulting sorted set in a new key
- - Scan a sorted set for members
bzPop
Description. Block until Redis can pop the highest or lowest scoring members from one or more ZSETs. There are two commands [
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
90 and # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
91 for popping the lowest and highest scoring elements respectively. ]Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
24Return valueARRAY. Either an array with the key member and score of the highest or lowest element or an empty array if the timeout was reached without an element to pop
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
25Note. Calling these functions with an array of keys or with a variable number of arguments is functionally identical
zAdd
Description. Add one or more members to a sorted set or update its score if it already exists
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
26Parameterskey. string options. array [optional] score. double
value. string score1. double value1. string
Long 1 if the element is added. 0 otherwise
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
27zCard, zSize
Description. Returns the cardinality of an ordered set
Parameterskey
Return valueLong, the set's cardinality
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
28Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
92 is an alias for # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
93 and will be removed in future versions of phprediszCount
Description. Returns the number of elements of the sorted set stored at the specified key which have scores in the range [start,end]. Adding a parenthesis before
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
94 or # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
95 excludes it from the range. +inf and -inf are also valid limitsParameterskey
start. string
end. string
DÀI kích thước của zRangeByScore tương ứng
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
29zIncrBy
Description. Increments the score of a member from a sorted set by a given amount
Parameterskey
value. [double] value that will be added to the member's score
member
DOUBLE the new value
ví dụ; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
30zinterstore, zInter
Description. Creates an intersection of sorted sets given in second argument. The result of the union will be stored in the sorted set defined by the first argument
The third optional argument defines
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
96 to apply to the sorted sets in input. In this case, the # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
96 will be multiplied by the score of each element in the sorted set before applying the aggregation. The forth argument defines the # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
98 option which specify how the results of the union are aggregatedParameterskeyOutput
arrayZSetKeys
arrayWeights
aggregateFunction Either "SUM", "MIN", or "MAX". defines the behaviour to use on duplicate entries during the zinterstore
LONG The number of values in the new sorted set
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
31Note.
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
99 is an alias for $redis = new Redis[];00 and will be removed in future versions of phpredis
zPop
Description. Can pop the highest or lowest scoring members from one ZSETs. There are two commands [
$redis = new Redis[];01 and
$redis = new Redis[];02 for popping the lowest and highest scoring elements respectively. ]Prototype
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
32Return valueARRAY. Either an array with the key member and score of the highest or lowest element or an empty array if there is no element available
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
33zRange
Description. Trả về một dải các phần tử từ tập hợp có thứ tự được lưu trữ tại khóa đã chỉ định, với các giá trị trong dải [bắt đầu, kết thúc]
Start and stop are interpreted as zero-based indices
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
23 the first element, # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
22 the second # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
15 the last element, # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
16 the penultimate Parameterskey start. Dài
kết thúc. Dài
có điểm. bool = sai
Array containing the values in specified range
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
34zRangeByScore, zRevRangeByScore
Sự miêu tả. Trả về các phần tử của tập hợp đã sắp xếp được lưu trữ tại khóa đã chỉ định có điểm số trong phạm vi [bắt đầu, kết thúc]. Thêm dấu ngoặc đơn trước
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
94 hoặc # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
95 sẽ loại trừ nó khỏi phạm vi. +inf và -inf cũng là các giới hạn hợp lệ. zRevRangeByScore trả về các mục tương tự theo thứ tự ngược lại, khi các tham số # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
94 và # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
95 được hoán đổiParameterskey
start. string
end. string
tùy chọn. mảng
Hai tùy chọn có sẵn.
$redis = new Redis[];11 và
$redis = new Redis[];12Return value
Array containing the values in specified range
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
35zRangeByLex
Sự miêu tả. Trả về một phạm vi từ điển của các phần tử trong một tập hợp được sắp xếp, giả sử các phần tử có cùng số điểm. Các giá trị tối thiểu và tối đa bắt buộc phải bắt đầu bằng '[' [không bao gồm], '[' [bao gồm] hoặc chính xác là các giá trị '-' [inf phủ định] hoặc '+' [inf khẳng định]. Lệnh phải được gọi với ba hoặc năm đối số hoặc sẽ trả về FALSE
ParametersChìa khóa. ZSET mà bạn muốn đối đầu
tối thiểu. Giá trị chữ và số tối thiểu bạn muốn nhận
tối đa. Giá trị chữ và số tối đa bạn muốn nhận
offset. Optional argument if you wish to start somewhere other than the first element
limit. Optional argument if you wish to limit the number of elements returned
Array containing the values in the specified range
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
36zRank, zRevRank
Description. Returns the rank of a given member in the specified sorted set, starting at 0 for the item with the smallest score. zRevRank starts at 0 for the item with the largest score
Parameterskey
member
Long, the item's rank
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
37zRem, zDelete, zRemove
Description. Delete one or more members from a sorted set
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
38Return valueLONG. The number of members deleted
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
39Note.
$redis = new Redis[];13 and
$redis = new Redis[];14 are an alias for
$redis = new Redis[];15 and will be removed in future versions of phpredis
zRemRangeByRank, zDeleteRangeByRank
Description. Deletes the elements of the sorted set stored at the specified key which have rank in the range [start,end]
Parameterskey
start. LONG
end. LONG
LONG The number of values deleted from the sorted set
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
40Note.
$redis = new Redis[];16 is an alias for
$redis = new Redis[];17 and will be removed in future versions of phpredis
zRemRangeByScore, zDeleteRangeByScore, zRemoveRangeByScore
Description. Deletes the elements of the sorted set stored at the specified key which have scores in the range [start,end]
Parameterskey
start. double or "+inf" or "-inf" string
end. double or "+inf" or "-inf" string
LONG The number of values deleted from the sorted set
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
41Note.
$redis = new Redis[];18 and
$redis = new Redis[];19 are an alias for
$redis = new Redis[];20 and will be removed in future versions of phpredis
zRevRange
Description. Returns the elements of the sorted set stored at the specified key in the range [start, end] in reverse order. start and stop are interpreted as zero-based indices
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
23 the first element, # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
22 the second # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
15 the last element, # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
16 the penultimate Parameterskey
start. long
kết thúc. Dài
có điểm. bool = sai
Array containing the values in specified range
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
42zScore
Description. Returns the score of a given member in the specified sorted set
Parameterskey
member
Double or FALSE when the value is not found
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
43zunionstore, zUnion
Description. Creates an union of sorted sets given in second argument. The result of the union will be stored in the sorted set defined by the first argument
The third optional argument defines
# Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
96 to apply to the sorted sets in input. In this case, the # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
96 will be multiplied by the score of each element in the sorted set before applying the aggregation. The forth argument defines the # Just run the 'echo' test
php tests/TestRedis.php --class Redis --test echo
98 option which specify how the results of the union are aggregatedParameterskeyOutput
arrayZSetKeys
arrayWeights
aggregateFunction Either "SUM", "MIN", or "MAX". defines the behaviour to use on duplicate entries during the zunionstore
LONG The number of values in the new sorted set
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
44Note.
$redis = new Redis[];28 is an alias for
$redis = new Redis[];29 and will be removed in future versions of phpredis
zScan
Description. Scan a sorted set for members, with optional pattern and count
Parameterskey. String, the set to scan
iterator. Long [reference], initialized to NULL
pattern. String [optional], the pattern to match
count. How many keys to return per iteration [Redis might return a different number]
Array, boolean PHPRedis will return matching keys from Redis, or FALSE when iteration is complete
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
45HyperLogLogs
pfAdd
Description. Adds the specified elements to the specified HyperLogLog
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
46ParametersKey
Array of values
Integer. 1 if at least 1 HyperLogLog internal register was altered. 0 otherwise
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
47pfCount
Description. Return the approximated cardinality of the set[s] observed by the HyperLogLog at key[s]
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
48ParametersKey or Array of keys
Return valueInteger. The approximated number of unique elements observed via
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
49pfMerge
Description. Merge N different HyperLogLogs into a single one
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
50ParametersDestination Key
Mảng khóa nguồn
BOOL.
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
24 on success, # Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23 on errorExample; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
51Geocoding
thêm địa lý
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
52Description. Thêm một hoặc nhiều mục không gian địa lý vào khóa đã chỉ định. This function must be called with at least one longitude, latitude, member triplet
Return valueInteger. The number of elements added to the geospatial key
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
53geoHash
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
54Description. Retrieve Geohash strings for one or more elements of a geospatial index
Return valueArray. One or more Redis Geohash encoded strings
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
55Output; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
56geoPos
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
57Description. Return longitude, latitude positions for each requested member
Return valueArray. One or more longitude/latitude positions
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
58Output; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
59GeoDist
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
60Description. Return the distance between two members in a geospatial set. If units are passed it must be one of the following values
- 'm' => Meters
- 'km' => Kilometers
- 'mi' => Miles
- 'ft' => Feet
Double. The distance between the two passed members in the units requested [meters by default]
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
61Output; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
62geoRadius
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
63Description. Return members of a set with geospatial information that are within the radius specified by the caller
Options ArrayThe georadius command can be called with various options that control how Redis returns results. The following table describes the options phpredis supports. All options are case insensitive
KeyValueDescriptionCOUNTinteger > 0Limit how many results are returnedWITHCOORDReturn longitude and latitude of matching membersWITHDISTReturn the distance from the centerWITHHASHReturn the raw geohash-encoded scoreASCSort results in ascending orderDESCSort results in descending orderSTOREkeyStore results in keySTOREDISTkeyStore the results as distances in keyNote. It doesn't make sense to pass both
$redis = new Redis[];32 and
$redis = new Redis[];33 options but if both are passed the last one passed will be used
Note. When using
$redis = new Redis[];34 in Redis Cluster, the store key must has to the same slot as the query key or you will get a
$redis = new Redis[];35 errorReturn value
Mixed. When no
$redis = new Redis[];36 option is passed, this function returns an array of results. If it is passed this function returns the number of stored entriesExample
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
64Output; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
65geoRadiusByMember
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
66Description. This method is identical to except that instead of passing a longitude and latitude as the "source" you pass an existing member in the geospatial set
Options ArraySee command for options array
Return valueArray. The zero or more entries that are close enough to the member given the distance and radius specified
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
67Output; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
68Streams
- - Acknowledge one or more pending messages
- - Add a message to a stream
- - Acquire ownership of a pending message
- - Remove a message from a stream
- - Manage consumer groups
- - Get information about a stream
- - Get the length of a stream
- - Inspect pending messages in a stream
- - Query a range of messages from a stream
- - Read message[s] from a stream
- - Read stream messages with a group and consumer
- - Query one or more messages from end to start
- - Trim a stream's size
xAck
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
69Description. Acknowledge one or more messages on behalf of a consumer group
Return valuelong. The number of messages Redis reports as acknowledged
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
70xAdd
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
71Description. Add a message to a stream
Return valueString. The added message ID
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
72xClaim
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
73Description. Claim ownership of one or more pending messages
Options Array
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
74Return valueMảng. Either an array of message IDs along with corresponding data, or just an array of IDs [if the 'JUSTID' option was passed]
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
75xDel
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
76Description. Delete one or more messages from a stream
Return valuelong. The number of messages removed
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
77xGroup
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
78Description. This command is used in order to create, destroy, or manage consumer groups
Return valueMixed. This command returns different types depending on the specific XGROUP command executed
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
79xInfo
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
80Description. Get information about a stream or consumer groups
Return valueMixed. This command returns different types depending on which subcommand is used
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
81xLen
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
82Description. Get the length of a given stream
Return valueDài. Số lượng tin nhắn trong luồng
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
83xĐang chờ xử lý
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
84Sự miêu tả. Get information about pending messages in a given stream
Return valueArray. Information about the pending messages, in various forms depending on the specific invocation of XPENDING
ví dụ; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
85xRange
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
86Description. Nhận một loạt tin nhắn từ một luồng nhất định
Return valueMảng. Các tin nhắn trong luồng trong phạm vi được yêu cầu
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
87xĐọc
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
88Sự miêu tả. Đọc dữ liệu từ một hoặc nhiều luồng và chỉ trả lại ID lớn hơn ID được gửi trong lệnh
Return valueMảng. Tin nhắn trong luồng mới hơn ID được chuyển đến Redis [nếu có]
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
89xReadGroup
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
90Sự miêu tả. Phương pháp này tương tự như xRead ngoại trừ việc nó hỗ trợ đọc tin nhắn cho một nhóm người tiêu dùng cụ thể
Return valueMảng. Các tin nhắn gửi đến nhóm người tiêu dùng này [nếu có]
ví dụ; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
91xRevRange
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
92Sự miêu tả. Điều này giống với xRange ngoại trừ kết quả trả về theo thứ tự ngược lại. Cũng lưu ý rằng Redis đảo ngược thứ tự "bắt đầu" và "kết thúc"
Return valueMảng. Các tin nhắn trong phạm vi được chỉ định
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
93xTrim
Prototype; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
94Sự miêu tả. Cắt bớt độ dài luồng đến mức tối đa nhất định. Nếu cờ "gần đúng" bị bỏ qua, Redis sẽ sử dụng kích thước của bạn làm gợi ý nhưng chỉ cắt bớt cây trong toàn bộ nút [điều này hiệu quả hơn]
Return valueDài. Số lượng tin nhắn được cắt bớt từ luồng
Example; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
95Quán rượu/phụ
- - Subscribe to channels by pattern
- - Đăng tin nhắn lên một kênh
- - Đăng ký kênh
- - Nội quan vào hệ thống phụ quán rượu / phụ
pĐăng ký
Sự miêu tả. Đăng ký kênh theo mẫu
Parametershoa văn. Một loạt các mẫu để phù hợp
gọi lại. Một chuỗi hoặc một mảng với một đối tượng và phương thức. Cuộc gọi lại sẽ nhận được bốn đối số [$redis, $pattern, $channel, $message]
giá trị trả về. Trộn. Bất kỳ giá trị trả về khác null nào trong cuộc gọi lại sẽ được trả lại cho người gọi
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
96publish
Sự miêu tả. Xuất bản tin nhắn lên các kênh. Cảnh báo. chức năng này có thể sẽ thay đổi trong tương lai
Parameterskênh truyền hình. một kênh để xuất bản lên
thông điệp. chuỗi
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
97đặt mua
Sự miêu tả. Đăng ký kênh. Cảnh báo. chức năng này có thể sẽ thay đổi trong tương lai
Parameterskênh truyền hình. một loạt các kênh để đăng ký
gọi lại. một chuỗi hoặc một Mảng[$instance, 'method_name']. Hàm gọi lại nhận 3 tham số. phiên bản redis, tên kênh và thông báo. giá trị trả về. Trộn. Bất kỳ giá trị trả về khác null nào trong cuộc gọi lại sẽ được trả lại cho người gọi
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
98quán rượu
Sự miêu tả. Một lệnh cho phép bạn lấy thông tin trên hệ thống Redis pub/sub
Parameterstừ khóa. Chuỗi, có thể là. "channels", "numsub", or "numpat"
argument. Tùy chọn, biến thể. Đối với lệnh con "kênh", bạn có thể chuyển một mẫu chuỗi. Đối với "numsub" một mảng tên kênh
KÊNH TRUYỀN HÌNH. Trả về một mảng trong đó các thành viên là các kênh phù hợp
NUMSUB. Trả về một mảng khóa/giá trị trong đó các khóa là tên kênh và giá trị là số lượng của chúng
NUMPAT. Trả về số nguyên chứa số đăng ký mẫu đang hoạt động
; Should the locking be enabled? Defaults to: 0.
redis.session.locking_enabled = 1
; How long should the lock live [in seconds]? Defaults to: value of max_execution_time.
redis.session.lock_expire = 60
; How long to wait between attempts to acquire lock, in microseconds [µs]?. Defaults to: 20000
redis.session.lock_wait_time = 50000
; Maximum number of times to retry [-1 means infinite]. Defaults to: 100
redis.session.lock_retries = 2000
99Chung
- - Thực thi bất kỳ lệnh chung nào đối với máy chủ
rawCommand
Sự miêu tả. Một phương thức để thực thi bất kỳ lệnh tùy ý nào đối với máy chủ Redis
ParametersPhương thức này có nhiều biến thể và nhận một số đối số động thuộc nhiều loại khác nhau [chuỗi, dài, kép], nhưng phải được truyền ít nhất một đối số [chính từ khóa lệnh]
Return valueThe return value can be various types depending on what the server itself returns. No post processing is done to the returned value and must be handled by the client code
Example# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
00Transactions
- - Enter and exit transactional mode
- - Xem khóa để sửa đổi bởi khách hàng khác
multi, exec, discard
Description. Vào và thoát khỏi chế độ giao dịch
Parameters[optional]
$redis = new Redis[];37 or
$redis = new Redis[];38. Defaults to
$redis = new Redis[];37. A
$redis = new Redis[];37 block of commands runs as a single transaction; a
$redis = new Redis[];38 block is simply transmitted faster to the server, but without any guarantee of atomicity.
$redis = new Redis[];42 cancels a transactionReturn value
$redis = new Redis[];43 trả về phiên bản Redis và chuyển sang đa chế độ. Khi ở chế độ đa phương thức, tất cả các cuộc gọi phương thức tiếp theo đều trả về cùng một đối tượng cho đến khi _____14_______44 được gọiExample
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
01watch, unwatch
Sự miêu tả. Theo dõi một khóa để sửa đổi bởi một khách hàng khác
If the key is modified between
$redis = new Redis[];45 and
$redis = new Redis[];46, the MULTI/EXEC transaction will fail [return
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
23]. $redis = new Redis[];48 cancels all the watching of all keys by this clientParameters
keys. string for one key or array for a list of keys
Example# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
02Scripting
- - Evaluate a LUA script serverside
- - Evaluate a LUA script serverside, from the SHA1 hash of the script instead of the script itself
- - Execute the Redis SCRIPT command to perform various operations on the scripting subsystem
- - The last error message [if any]
- - Clear the last error message
- - A utility method to prefix the value with the prefix setting for phpredis
- - A utility method to unserialize data with whatever serializer is set up
- - A utility method to serialize data with whatever serializer is set up
đánh giá
Description. Evaluate a LUA script serverside
Parametersscript string
args array, optional
num_keys int, optional
Mixed. What is returned depends on what the LUA script itself returns, which could be a scalar value [int/string], or an array. Các mảng được trả về cũng có thể chứa các mảng khác, nếu đó là cách nó được thiết lập trong tập lệnh LUA của bạn. If there is an error executing the LUA script, the getLastError[] function can tell you the message that came back from Redis [e. g. compile error]
ví dụ# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
03evalSha
Sự miêu tả. Đánh giá phía máy chủ tập lệnh LUA, từ hàm băm SHA1 của tập lệnh thay vì chính tập lệnh đó
Để chạy lệnh này, Redis sẽ phải tải tập lệnh, bằng cách chạy tập lệnh hoặc thông qua lệnh SCRIPT LOAD
Parameterschuỗi script_sha. The sha1 encoded hash of the script you want to run
mảng args, tùy chọn. Các đối số để chuyển đến tập lệnh LUA
num_keys int, tùy chọn. Số lượng đối số sẽ đi vào mảng KEYS, so với. mảng ARGV khi Redis quay tập lệnh
Trộn. Xem EVAL
ví dụ# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
04script
Sự miêu tả. Thực thi lệnh Redis SCRIPT để thực hiện các thao tác khác nhau trên hệ thống con tập lệnh
Usage# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
05Return value- SCRIPT LOAD sẽ trả về hàm băm SHA1 của tập lệnh đã truyền nếu thành công và FALSE nếu thất bại
- SCRIPT FLUSH phải luôn trả về TRUE
- SCRIPT KILL sẽ trả về true nếu script có thể bị kill và false nếu không
- SCRIPT EXISTS sẽ trả về một mảng có TRUE hoặc FALSE cho mỗi tập lệnh được truyền
khách hàng
Description. Ban hành lệnh CLIENT với các đối số khác nhau
The Redis CLIENT command can be used in four ways
- DANH SÁCH KHÁCH HÀNG
- TÊN KHÁCH HÀNG
- TÊN KHÁCH HÀNG [tên]
- KHÁCH HÀNG GIẾT [ip. port]
# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
06Return valueĐiều này sẽ khác nhau tùy thuộc vào lệnh máy khách nào được thực thi
- DANH SÁCH KHÁCH HÀNG sẽ trả về một mảng các mảng có thông tin khách hàng
- CLIENT GETNAME sẽ trả về tên máy khách hoặc false nếu chưa đặt
- CLIENT SETNAME will return true if it can be set and false if not
- CLIENT KILL sẽ trả về true nếu client có thể bị giết và false nếu không
Ghi chú. phpredis sẽ cố gắng kết nối lại để bạn thực sự có thể hủy kết nối của chính mình nhưng có thể không nhận thấy việc mất kết nối đó
getLastError
Description. Thông báo lỗi cuối cùng [nếu có]
Parametersnone
Return valueA string with the last returned script based error message, or NULL if there is no error
ví dụ# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
07ClearLastError
Sự miêu tả. Xóa thông báo lỗi cuối cùng
Parametersnone
Return valueĐÚNG SỰ THẬT
ví dụ# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
08_tiếp đầu ngữ
Sự miêu tả. Một phương thức tiện ích để thêm tiền tố vào giá trị với cài đặt tiền tố cho phpredis
Parameterschuỗi giá trị. Giá trị bạn muốn tiền tố
Return valueNếu tiền tố được thiết lập, giá trị hiện có tiền tố. Nếu không có tiền tố, giá trị sẽ được trả về không thay đổi
ví dụ# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
09_serialize
Sự miêu tả. Một phương pháp tiện ích để tuần tự hóa các giá trị theo cách thủ công
Phương pháp này cho phép bạn tuần tự hóa một giá trị với bất kỳ bộ tuần tự hóa nào được định cấu hình, theo cách thủ công. Điều này có thể hữu ích cho việc tuần tự hóa/hủy tuần tự hóa dữ liệu vào và ra khỏi các lệnh EVAL vì phpredis không thể tự động thực hiện việc này. Lưu ý rằng nếu không có bộ nối tiếp nào được đặt, phpredis sẽ thay đổi giá trị Mảng thành 'Mảng' và Đối tượng thành 'Đối tượng'
Parametersvalue. Mixed. The value to be serialized
ví dụ# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
10_unserialize
Description. Một phương thức tiện ích để hủy xác thực dữ liệu với bất kỳ bộ nối tiếp nào được thiết lập
Nếu không có bộ nối tiếp nào được đặt, giá trị sẽ được trả về không thay đổi. If there is a serializer set up, and the data passed in is malformed, an exception will be thrown. This can be useful if phpredis is serializing values, and you return something from redis in a LUA script that is serialized
Parameterschuỗi giá trị. The value to be unserialized
ví dụ# Run tests for Redis class [note this is the default]
php tests/TestRedis.php --class Redis
# Run tests for RedisArray class
tests/mkring.sh start
php tests/TestRedis.php --class RedisArray
tests/mkring.sh stop
# Run tests for the RedisCluster class
tests/make-cluster.sh start
php tests/TestRedis.php --class RedisCluster
tests/make-cluster.sh stop
# Run tests for RedisSentinel class
php tests/TestRedis.php --class RedisSentinel
11Introspection
đã kết nối
Description. Một phương pháp để xác định xem một đối tượng phpredis có nghĩ rằng nó được kết nối với máy chủ hay không
ParametersNone
Return valueBoolean Returns TRUE if phpredis thinks it's connected and FALSE if not
getHost
Description. Truy xuất máy chủ lưu trữ hoặc ổ cắm unix mà chúng tôi đã kết nối với
ParametersNone
Return valueMixed The host or unix socket we're connected to or FALSE if we're not connected
getPort
Sự miêu tả. Get the port we're connected to
ParametersNone
Return valueHỗn hợp Trả về cổng chúng tôi đã kết nối hoặc FALSE nếu chúng tôi không kết nối
getDbNum
Sự miêu tả. Get the database number phpredis is pointed to
ParametersNone
Return valueMixed Returns the database number [LONG] phpredis thinks it's pointing to or FALSE if we're not connected
getTimeout
Description. Nhận thời gian chờ [ghi] được sử dụng cho phpredis
ParametersNone
Return valueHỗn hợp Thời gian chờ [DOUBLE] được chỉ định trong cuộc gọi kết nối của chúng tôi hoặc SAI nếu chúng tôi không được kết nối
getReadTimeout
Sự miêu tả. Nhận thời gian chờ đọc được chỉ định cho phpredis hoặc FALSE nếu chúng tôi không được kết nối
ParametersNone
Return valueMixed Returns the read timeout [which can be set using setOption and Redis. OPT_READ_TIMEOUT] hoặc FALSE nếu chúng tôi không được kết nối
getPersistentID
Sự miêu tả. Nhận ID liên tục mà phpredis đang sử dụng
ParametersNone
Return valueKết hợp Trả về id liên tục mà phpredis đang sử dụng [sẽ chỉ được đặt nếu được kết nối với pconnect], NULL nếu chúng tôi không sử dụng ID liên tục và FALSE nếu chúng tôi không kết nối
getAuth
Description. Lấy mật khẩu [hoặc tên người dùng và mật khẩu nếu sử dụng Redis 6 ACL] được sử dụng để xác thực kết nối
Parameters
None
Return value
Hỗn hợp Trả về NULL nếu không có tên người dùng/mật khẩu nào được đặt, chuỗi mật khẩu nếu mật khẩu được đặt và mảng
$redis = new Redis[];49 nếu được xác thực bằng tên người dùng và mật khẩu