[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6269":3},{"id":4,"name":5,"fullName":6,"owner":5,"repo":5,"description":7,"homepage":8,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":18,"rankGlobal":9,"rankLanguage":9,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":20,"hasPages":22,"topics":23,"createdAt":9,"pushedAt":9,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":15,"starSnapshotCount":15,"syncStatus":33,"lastSyncTime":34,"discoverSource":35},6269,"phpredis","phpredis\u002Fphpredis","A PHP extension for Redis","",null,"C",10218,2139,448,99,0,3,11,72.59,"Other",false,"develop",true,[24,25,26,27,28,29],"cluster","keydb","php","redis","redis-cluster","valkey","2026-06-12 04:00:27","# PhpRedis\n\n[![Build Status](https:\u002F\u002Fgithub.com\u002Fphpredis\u002Fphpredis\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fphpredis\u002Fphpredis\u002Factions\u002Fworkflows\u002Fci.yml)\n[![Coverity Scan Build Status](https:\u002F\u002Fscan.coverity.com\u002Fprojects\u002F13205\u002Fbadge.svg)](https:\u002F\u002Fscan.coverity.com\u002Fprojects\u002Fphpredis-phpredis)\n[![PHP version](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fphp-%3E%3D%207.4-8892BF.svg)](https:\u002F\u002Fgithub.com\u002Fphpredis\u002Fphpredis)\n\nThe phpredis extension provides an API for communicating with the [Redis](http:\u002F\u002Fredis.io\u002F) key-value store. [Valkey](https:\u002F\u002Fvalkey.io\u002F) and [KeyDB](https:\u002F\u002Fdocs.keydb.dev\u002F) are supported as well.\n\nIt is released under the [PHP License, version 3.01](http:\u002F\u002Fwww.php.net\u002Flicense\u002F3_01.txt).\n\nYou can send comments, patches, questions [here on github](https:\u002F\u002Fgithub.com\u002Fphpredis\u002Fphpredis\u002Fissues), to [Michael](mailto:michael.grunder@gmail.com) ([Twitter](https:\u002F\u002Ftwitter.com\u002Fgrumi78), \u003Ca rel=\"me\" href=\"https:\u002F\u002Fphpc.social\u002F@mgrunder\">Mastodon\u003C\u002Fa>), [Pavlo](mailto:p.yatsukhnenko@gmail.com) ([@yatsukhnenko](https:\u002F\u002Ftwitter.com\u002Fyatsukhnenko)), or [Nicolas](mailto:n.favrefelix@gmail.com) ([@yowgi](https:\u002F\u002Ftwitter.com\u002Fyowgi)).\n\n## Sponsors\n\n\u003Cdiv align=\"center\">\n  \u003Cbr>\n  \u003Ca href=\"https:\u002F\u002Frelay.so\">\n    \u003Cimg src=\"https:\u002F\u002Fs3.us-east-1.amazonaws.com\u002Fassets.relay.so\u002Fimg\u002Fwordmark-purple.svg\" align=\"center\" alt=\"The next-generation caching layer for PHP.\" width=\"275\">\n  \u003C\u002Fa>\n  \u003Cbr>\u003Cbr>\u003Cbr>\n  \u003Ca href=\"https:\u002F\u002Fobjectcache.pro\">\u003Cimg src=\"https:\u002F\u002Fobjectcache.pro\u002Fassets\u002Fwordmark-padded.png\" align=\"center\" alt=\"Object Cache Pro\" width=\"200\">\u003C\u002Fa>&nbsp;\n  \u003Ca href=\"https:\u002F\u002Faudiomack.com\">\u003Cimg src=\"https:\u002F\u002Fstyleguide.audiomack.com\u002Fassets\u002Fdl\u002Finline-orange-large.png\" align=\"center\" alt=\"Audiomack.com\" width=\"150\">\u003C\u002Fa>&nbsp;\n  \u003Ca href=\"https:\u002F\u002Fbluehost.com\">\u003Cimg src=\"https:\u002F\u002Fupload.wikimedia.org\u002Fwikipedia\u002Fcommons\u002F2\u002F22\u002FBluehost-logo.png\" align=\"center\" alt=\"Bluehost.com\" width=\"150\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fopenlms.net\">\u003Cimg src=\"https:\u002F\u002Fsupport.openlms.net\u002Fhc\u002Ftheming_assets\u002F01HZPV3CVP3Y6P7G6MT14NP6V1\" align=\"center\" alt=\"OpenLMS.net\" width=\"125\">\u003C\u002Fa>\n  \u003Cbr>\u003Cbr>\n\u003C\u002Fdiv>\n\n## Become a Sponsor\nPhpRedis will always be free and open source software and if you or your company has found it useful please consider supporting the project. Developing a large, complex, and performant library like PhpRedis takes a great deal of time and effort, and support is greatly appreciated! :heart:\n\nThe ongoing development of PhpRedis is made possible thanks to the generous support of [Relay](https:\u002F\u002Frelay.so), which funds the vast majority of work on the project. Relay is a high-performance in-memory cache and drop-in replacement for PhpRedis, which handles millions of requests per second without breaking a sweat.\n\nThe best way to support the project is through [GitHub Sponsors](https:\u002F\u002Fgithub.com\u002Fsponsors\u002Fmichael-grunder). Many of the reward tiers grant access to our [Slack](https:\u002F\u002Fphpredis.slack.com) where [myself](https:\u002F\u002Fgithub.com\u002Fmichael-grunder) and [Pavlo](https:\u002F\u002Fgithub.com\u002Fyatsukhnenko) are regularly available to answer questions. Additionally this will allow you to provide feedback on which fixes and features to prioritize. You can also make a one-time contribution with [PayPal](https:\u002F\u002Fwww.paypal.me\u002Fmichaelgrunder\u002F5).\n\n## Table of contents\n1. [Installing\u002FConfiguring](#installingconfiguring)\n   * [Installation](#installation)\n   * [PHP Session handler](#php-session-handler)\n   * [Distributed Redis Array](.\u002Farrays.md#readme)\n   * [Redis Cluster support](.\u002Fcluster.md#readme)\n   * [Redis Sentinel support](.\u002Fsentinel.md#readme)\n   * [Running the unit tests](#running-the-unit-tests)\n2. [API Documentation](#api-documentation)\n3. [Classes and methods](#classes-and-methods)\n   * [Usage](#usage)\n   * [Connection](#connection)\n   * [Retry and backoff](#retry-and-backoff)\n   * [Server](#server)\n   * [Keys and strings](#keys-and-strings)\n   * [Hashes](#hashes)\n   * [Lists](#lists)\n   * [Sets](#sets)\n   * [Sorted sets](#sorted-sets)\n   * [HyperLogLogs](#hyperloglogs)\n   * [Geocoding](#geocoding)\n   * [Streams](#streams)\n   * [Pub\u002Fsub](#pubsub)\n   * [Transactions](#transactions)\n   * [Scripting](#scripting)\n   * [Local Helper Methods](#local-helper-methods)\n   * [Introspection](#introspection)\n\n## Installing\u002FConfiguring\n\n### Installation\n\nFor everything you should need to install PhpRedis on your system,\nsee the [INSTALL.md](.\u002FINSTALL.md) page.\n\n### PHP Session handler\n\nphpredis can be used to store PHP sessions. To do this, configure `session.save_handler` and `session.save_path` in your php.ini to tell phpredis where to store the sessions.\n\n`session.save_path` can have a simple `host:port` format too, but you need to provide the `tcp:\u002F\u002F` scheme if you want to use the parameters. The following parameters are available:\n\n* weight (integer): the weight of a host is used in comparison with the others 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\u002F(1+2+2)) while *host2* and *host3* each store 40% (2\u002F(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.\n* 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).\n* read_timeout (float): the timeout for read operations on an established connection, expressed in seconds. If a Redis response is not received within this time, the session operation fails. The default is `0` (no timeout), meaning PHP can hang indefinitely if Redis becomes unresponsive or a connection goes stale. Setting this to a low value (e.g. `2.5`) is strongly recommended in production environments.\n* persistent (integer, should be 1 or 0): defines if a persistent connection should be used. The default value is `0` (persistent connection is not used).\n* 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.\n* auth (string, or an array with one or two elements): used to authenticate with the server prior to sending commands.\n* database (integer): selects a different database.\n\nSessions have a lifetime expressed in seconds and stored in the INI variable \"session.gc_maxlifetime\". You can change it with [`ini_set()`](http:\u002F\u002Fphp.net\u002Fini_set).\nThe session handler requires a version of Redis supporting `EX` and `NX` options of `SET` command (at least 2.6.12).\nphpredis can also connect to a unix domain socket: `session.save_path = \"unix:\u002F\u002F\u002Fvar\u002Frun\u002Fredis\u002Fredis.sock?persistent=1&weight=1&database=0\"`.\n\n#### Examples\n\nMultiple Redis servers:\n~~~\nsession.save_handler = redis\nsession.save_path = \"tcp:\u002F\u002Fhost1:6379?weight=1, tcp:\u002F\u002Fhost2:6379?weight=2&timeout=2.5, tcp:\u002F\u002Fhost3:6379?weight=2&read_timeout=2.5\"\n~~~\n\nLogin to Redis using username and password:\n~~~\nsession.save_handler = redis\nsession.save_path = \"tcp:\u002F\u002F127.0.0.1:6379?auth[]=user&auth[]=password\"\n~~~\n\nLogin to Redis using username, password, and set prefix:\n~~~\nsession.save_handler = redis\nsession.save_path = \"tcp:\u002F\u002F127.0.0.1:6379?auth[]=user&auth[]=password&prefix=user_PHPREDIS_SESSION:\"\n~~~\n\n#### Session locking\n\n**Support**: Locking feature is currently only supported for Redis setup with single master instance (e.g. classic master\u002Fslave Sentinel environment).\nSo locking may not work properly in RedisArray or RedisCluster environments.\n\nThe following INI variables can be used to configure session locking:\n~~~\n; Should the locking be enabled? Defaults to: 0.\nredis.session.locking_enabled = 1\n; How long should the lock live (in seconds)? Defaults to: value of max_execution_time.\nredis.session.lock_expire = 60\n; How long to wait between attempts to acquire lock, in microseconds (µs)?. Defaults to: 20000\nredis.session.lock_wait_time = 50000\n; Maximum number of times to retry (-1 means infinite). Defaults to: 100\nredis.session.lock_retries = 2000\n~~~\n\n#### Session compression\n\nThe following INI variables can be used to configure session compression:\n~~~\n; Should session compression be enabled? Possible values are zstd, lzf, lz4, none. Defaults to: none\nredis.session.compression = zstd\n; What compression level should be used? Compression level depends on used library. For most deployments range 1-9 should be fine. Defaults to: 3\nredis.session.compression_level = 3\n~~~\n\n### Running the unit tests\n\nphpredis uses a small custom unit test suite for testing functionality of the various classes.  To run tests, simply do the following:\n\n~~~\n# Run tests for Redis class (note this is the default)\nphp tests\u002FTestRedis.php --class Redis\n\n# Run tests for RedisArray class\ntests\u002Fmkring.sh start\nphp tests\u002FTestRedis.php --class RedisArray\ntests\u002Fmkring.sh stop\n\n# Run tests for the RedisCluster class\ntests\u002Fmake-cluster.sh start\nphp tests\u002FTestRedis.php --class RedisCluster\ntests\u002Fmake-cluster.sh stop\n\n# Run tests for RedisSentinel class\nphp tests\u002FTestRedis.php --class RedisSentinel\n~~~\n\nNote that it is possible to run only tests which match a substring of the test itself by passing the additional argument '--test \u003Cstr>' when invoking.\n\n~~~\n# Just run the 'echo' test\nphp tests\u002FTestRedis.php --class Redis --test echo\n~~~\n\n## API Documentation\n\nThe [API Documentation](https:\u002F\u002Fphpredis.github.io\u002Fphpredis) are a work in progress, but will eventually replace our **ONE README TO RULE THEM ALL** docs.\n\n## Classes and methods\n\n### Usage\n\n1. [Class Redis](#class-redis)\n1. [Class RedisException](#class-redisexception)\n1. [Predefined constants](#predefined-constants)\n\n#### Class Redis\n-----\n_**Description**_: Creates a Redis client\n\n###### *Example*\n\n~~~php\n$redis = new Redis();\n~~~\n\nStarting from version 6.0.0 it's possible to specify configuration options.\nThis allows to connect lazily to the server without explicitly invoking `connect` \u002F `pconnect`.\n\n###### *Example*\n\n~~~php\n$redis = new Redis([\n    'host' => '127.0.0.1',\n    'port' => 6379,\n    'connectTimeout' => 2.5,\n    'auth' => ['phpredis', 'phpredis'],\n    'database' => 2,\n    'ssl' => ['verify_peer' => false],\n    'backoff' => [\n        'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER,\n        'base' => 500,\n        'cap' => 750,\n    ],\n]);\n~~~\n\n###### *Parameters* (optional)\n\n*host*: string, the hostname\u002FFQDN\u002FIP address or the path to a unix domain socket; since v5.0.0 it is possible to specify schema\n*port*: int, actual port (e.g. `6379`) or `-1` (or `0`) for unix domain socket; setting to \u003C `0` with non-UDS will assume default of `6379`\n*connectTimeout*: float, value in seconds (default is 0 meaning unlimited)\n*retryInterval*: int, value in milliseconds (optional)\n*readTimeout*: float, value in seconds (default is 0 meaning unlimited)\n*persistent*: mixed, If the value is a string it is used as a persistent ID. Non-strings are cast to boolean.\n*auth*: mixed, authentication information\n*database*: int, database number\n*ssl*: array, SSL context options\n\n#### Class RedisException\n-----\nphpredis throws a [RedisException](#class-redisexception) object if it can't reach the Redis server. That can happen in case of connectivity issues,\nif the Redis service is down, or if the Redis host is overloaded. In any other problematic case that does not involve an\nunreachable server (such as a key not existing, an invalid command, etc), phpredis will return `FALSE`.\n\n#### Predefined constants\n-----\n_**Description**_: Available Redis Constants\n\nRedis data types, as returned by [type](#type)\n~~~\nRedis::REDIS_STRING - String\nRedis::REDIS_SET - Set\nRedis::REDIS_LIST - List\nRedis::REDIS_ZSET - Sorted set\nRedis::REDIS_HASH - Hash\nRedis::REDIS_STREAM - Stream    \nRedis::REDIS_VECTORSET - Vector set\nRedis::REDIS_NOT_FOUND - Not found \u002F other\n~~~\n\n### Connection\n\n1. [connect, open](#connect-open) - Connect to a server\n1. [pconnect, popen](#pconnect-popen) - Connect to a server (persistent)\n1. [auth](#auth) - Authenticate to the server\n1. [select](#select) - Change the selected database for the current connection\n1. [swapdb](#swapdb) - Swaps two Redis databases\n1. [close](#close) - Close the connection\n1. [setOption](#setoption) - Set client option\n1. [getOption](#getoption) - Get client option\n1. [ping](#ping) - Ping the server\n1. [echo](#echo) - Echo the given string\n\n#### connect, open\n-----\n_**Description**_: Connects to a Redis instance. If phpredis cannot reach the server it will usually throw a [`RedisException`](#class-redisexception); only rarely will `FALSE` be returned without an exception.\n\n###### *Parameters*\n\n*host*: string, *host*: string, the hostname\u002FFQDN\u002FIP address or the path to a unix domain socket; since v5.0.0 it is possible to specify schema\n*port*: int, actual port (e.g. `6379`) or `-1` (or `0`) for unix domain socket; setting to \u003C `0` with non-UDS will assume default of `6379`, optional\n*timeout*: float, value in seconds (optional, default is 0 meaning it will use default_socket_timeout)\n*reserved*: should be '' if retry_interval is specified\n*retry_interval*: int, value in milliseconds, optional\n*read_timeout*: float, value in seconds (optional, default is 0 meaning it will use default_socket_timeout)\n*others*: array, with PhpRedis >= 5.3.0, it allows setting _auth_ and [_stream_](https:\u002F\u002Fwww.php.net\u002Fmanual\u002Fen\u002Fcontext.ssl.php) configuration.\n\n###### *Return value*\n\n*BOOL*: `TRUE` on success. Failures typically raise a `RedisException`, though in some edge cases `FALSE` may be returned instead.\n\n###### *Example*\n\n~~~php\n$redis->connect('127.0.0.1', 6379);\n$redis->connect('127.0.0.1'); \u002F\u002F port 6379 by default\n$redis->connect('tls:\u002F\u002F127.0.0.1', 6379); \u002F\u002F enable transport level security.\n$redis->connect('tls:\u002F\u002F127.0.0.1'); \u002F\u002F enable transport level security, port 6379 by default.\n$redis->connect('127.0.0.1', 6379, 2.5); \u002F\u002F 2.5 sec timeout.\n$redis->connect('\u002Ftmp\u002Fredis.sock'); \u002F\u002F unix domain socket.\n$redis->connect('127.0.0.1', 6379, 1, '', 100); \u002F\u002F 1 sec timeout, 100ms delay between reconnection attempts.\n$redis->connect('\u002Ftmp\u002Fredis.sock', 0, 1.5, NULL, 0, 1.5); \u002F\u002F Unix socket with 1.5s timeouts (connect and read)\n\n\u002F* With PhpRedis >= 5.3.0 you can specify authentication and stream information on connect *\u002F\n$redis->connect('127.0.0.1', 6379, 1, '', 0, 0, ['auth' => ['phpredis', 'phpredis']]);\n\n\u002F* TLS connections can customise the underlying PHP stream context *\u002F\n$redis->connect('tls:\u002F\u002Fredis.example.com', 6380, 1.5, null, 0, 0, [\n    'auth' => ['app-user', 'strong-password'],\n    'stream' => [\n        'verify_peer' => true,                 \u002F\u002F validate the server certificate against cafile\u002Fcapath\n        'verify_peer_name' => true,            \u002F\u002F require the certificate common\u002FSAN name to match peer_name\n        'peer_name' => 'redis.example.com',    \u002F\u002F expected hostname presented by the server certificate\n        'cafile' => '\u002Fetc\u002Fssl\u002Fredis-ca.pem',   \u002F\u002F CA or bundle used to trust the server certificate\n        'capath' => '\u002Fetc\u002Fssl\u002Fcerts',          \u002F\u002F directory alternative to cafile\n        'allow_self_signed' => false,          \u002F\u002F set to true if you rely on a self-signed certificate\n        'local_cert' => '\u002Fetc\u002Fssl\u002Fclient.crt', \u002F\u002F client certificate for mutual TLS (optional)\n        'local_pk' => '\u002Fetc\u002Fssl\u002Fclient.key',   \u002F\u002F private key that matches local_cert (optional)\n        'passphrase' => 'secret',              \u002F\u002F passphrase for local_pk if it is encrypted (optional)\n        'ciphers' => 'HIGH:!aNULL:!MD5',       \u002F\u002F TLS cipher list provided to OpenSSL (optional)\n    ],\n]);\n\ntry {\n    $redis->connect('redis.invalid', 6379);\n} catch (RedisException $ex) {\n    echo \"Connection failed: {$ex->getMessage()}\";\n}\n~~~\n\nWhen you pass a `stream` key PhpRedis forwards the options to [`stream_socket_client`](https:\u002F\u002Fwww.php.net\u002Fmanual\u002Fen\u002Fcontext.ssl.php).\nCommonly used options include:\n\n- `verify_peer`, `verify_peer_name`, `peer_name`: control server certificate validation behaviour.\n- `cafile`\u002F`capath`: provide the trusted certificate authority bundle when the default store is insufficient.\n- `allow_self_signed`: permits self-signed certificates when set to `true`.\n- `local_cert`, `local_pk`, `passphrase`: configure client-side certificates for mutual TLS.\n- `ciphers`: restrict the negotiated TLS cipher suites.\n- Any other SSL context option supported by PHP (e.g. `SNI_enabled`, `disable_compression`) can also be supplied.\n\nThe same array format can be used with `pconnect`\u002F`popen`.\n\n**Note:** `open` is an alias for `connect` and will be removed in future versions of phpredis.\n\n#### pconnect, popen\n-----\n_**Description**_: Connects to a Redis instance or reuse a connection already established with `pconnect`\u002F`popen`.\n\nThe connection will not be closed on end of request until the php process ends.\nSo be prepared for too many open FD's errors (specially on redis server side) when using persistent\nconnections on many servers connecting to one redis server.\n\nAlso more than one persistent connection can be made, identified by either host + port + timeout\nor host + persistent_id or unix socket + timeout.\n\nSince v4.2.1, it became possible to use connection pooling by setting INI variable `redis.pconnect.pooling_enabled` to 1.\n\nThis feature is not available in threaded versions. `pconnect` and `popen` then work like their non\npersistent equivalents.\n\n###### *Parameters*\n\n*host*: string, *host*: string, the hostname\u002FFQDN\u002FIP address or the path to a unix domain socket; since v5.0.0 it is possible to specify schema\n*port*: int, actual port (e.g. `6379`) or `-1` (or `0`) for unix domain socket; setting to \u003C `0` with non-UDS will assume default of `6379`, optional\n*timeout*: float, value in seconds (optional, default is 0 meaning it will use default_socket_timeout)\n*persistent_id*: string. identity for the requested persistent connection\n*retry_interval*: int, value in milliseconds (optional)\n*read_timeout*: float, value in seconds (optional, default is 0 meaning it will use default_socket_timeout)\n\n###### *Return value*\n\n*BOOL*: `TRUE` on success, `FALSE` on error.\n\n###### *Example*\n\n~~~php\n$redis->pconnect('127.0.0.1', 6379);\n$redis->pconnect('127.0.0.1'); \u002F\u002F port 6379 by default - same connection like before.\n$redis->pconnect('tls:\u002F\u002F127.0.0.1', 6379); \u002F\u002F enable transport level security.\n$redis->pconnect('tls:\u002F\u002F127.0.0.1'); \u002F\u002F enable transport level security, port 6379 by default.\n$redis->pconnect('127.0.0.1', 6379, 2.5); \u002F\u002F 2.5 sec timeout and would be another connection than the two before.\n$redis->pconnect('127.0.0.1', 6379, 2.5, 'x'); \u002F\u002F x is sent as persistent_id and would be another connection than the three before.\n$redis->pconnect('\u002Ftmp\u002Fredis.sock'); \u002F\u002F unix domain socket - would be another connection than the four before.\n~~~\n\n**Note:** `popen` is an alias for `pconnect` and will be removed in future versions of phpredis.\n\n#### auth\n-----\n_**Description**_: Authenticate the connection using a password or a username and password.\n*Warning*: The password is sent in plain-text over the network.\n\n###### *Parameters*\n*MIXED*: password\n\n###### *Return value*\n*BOOL*: `TRUE` if the connection is authenticated, `FALSE` otherwise.\n\n*Note*: In order to authenticate with a username and password you need Redis >= 6.0.\n\n###### *Example*\n~~~php\n\u002F* Authenticate with the password 'foobared' *\u002F\n$redis->auth('foobared');\n\n\u002F* Authenticate with the username 'phpredis', and password 'haxx00r' *\u002F\n$redis->auth(['phpredis', 'haxx00r']);\n\n\u002F* Authenticate with the password 'foobared' *\u002F\n$redis->auth(['foobared']);\n\n\u002F* You can also use an associative array specifying user and pass *\u002F\n$redis->auth(['user' => 'phpredis', 'pass' => 'phpredis']);\n$redis->auth(['pass' => 'phpredis']);\n~~~\n\n#### select\n-----\n_**Description**_: Change the selected database for the current connection.\n\n###### *Parameters*\n*INTEGER*: dbindex, the database number to switch to.\n\n###### *Return value*\n`TRUE` in case of success, `FALSE` in case of failure.\n###### *Example*\nSee method for example: [move](#move)\n\n#### swapdb\n-----\n_**Description**_:  Swap one Redis database with another atomically\n\n###### *Parameters*\n*INTEGER*: db1\n*INTEGER*: db2\n\n###### *Return value*\n`TRUE` on success and `FALSE` on failure.\n\n*Note*: Requires Redis >= 4.0.0\n\n###### *Example*\n~~~php\n$redis->swapdb(0, 1); \u002F* Swaps DB 0 with DB 1 atomically *\u002F\n~~~\n\n#### close\n-----\n_**Description**_: Disconnects from the Redis instance.\n\n*Note*: Closing a persistent connection requires PhpRedis >= 4.2.0.\n\n###### *Parameters*\nNone.\n\n###### *Return value*\n*BOOL*: `TRUE` on success, `FALSE` on failure.\n\n#### setOption\n-----\n_**Description**_: Set client option.\n\n###### *Parameters*\n*parameter name*\n*parameter value*\n\n###### *Return value*\n*BOOL*: `TRUE` on success, `FALSE` on error.\n\n###### *Example*\n~~~php\n$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);\t  \u002F\u002F Don't serialize data\n$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);\t  \u002F\u002F Use built-in serialize\u002Funserialize\n$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY); \u002F\u002F Use igBinary serialize\u002Funserialize\n$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_MSGPACK);  \u002F\u002F Use msgpack serialize\u002Funserialize\n$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_JSON);  \u002F\u002F Use JSON to serialize\u002Funserialize\n\n$redis->setOption(Redis::OPT_PREFIX, 'myAppName:');\t\u002F\u002F use custom prefix on all keys\n\n\u002F* Options for the SCAN family of commands, indicating whether to abstract\n   empty results from the user. If set to SCAN_NORETRY (the default), phpredis\n   will just issue one SCAN command at a time, sometimes returning an empty\n   array of results. If set to SCAN_RETRY, phpredis will retry the scan command\n   until keys come back OR Redis returns an iterator of zero\n*\u002F\n$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_NORETRY);\n$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY);\n\n\u002F* Scan can also be configured to automatically prepend the currently set PhpRedis\n   prefix to any MATCH pattern. *\u002F\n$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_PREFIX);\n$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_NOPREFIX);\n~~~\n\n\n#### getOption\n-----\n_**Description**_: Get client option.\n\n###### *Parameters*\n*parameter name*\n\n###### *Return value*\nParameter value.\n\n###### *Example*\n~~~php\n\u002F\u002F return Redis::SERIALIZER_NONE, Redis::SERIALIZER_PHP,\n\u002F\u002F        Redis::SERIALIZER_IGBINARY, Redis::SERIALIZER_MSGPACK or Redis::SERIALIZER_JSON\n$redis->getOption(Redis::OPT_SERIALIZER);\n~~~\n\n#### ping\n-----\n_**Description**_: Check the current connection status.\n\n###### *Prototype*\n~~~php\n$redis->ping([string $message]);\n~~~\n\n###### *Return value*\n*Mixed*:  This method returns `TRUE` on success, or the passed string if called with an argument.\n\n###### *Example*\n~~~php\n\u002F* When called without an argument, PING returns `TRUE` *\u002F\n$redis->ping();\n\n\u002F* If passed an argument, that argument is returned.  Here 'hello' will be returned *\u002F\n$redis->ping('hello');\n~~~\n\n*Note*:  Prior to PhpRedis 5.0.0 this command simply returned the string `+PONG`.\n\n#### echo\n-----\n_**Description**_: Sends a string to Redis, which replies with the same string\n\n###### *Parameters*\n\n*STRING*: The message to send.\n\n###### *Return value*\n\n*STRING*: the same message.\n\n### Retry and backoff\n\n1. [Maximum retries](#maximum-retries)\n1. [Backoff algorithms](#backoff-algorithms)\n\n#### Maximum retries\nYou can set and get the maximum retries upon connection issues using the `OPT_MAX_RETRIES` option. Note that this is the number of _retries_, meaning if you set this option to _n_, there will be a maximum _n+1_ attempts overall. Defaults to 10.\n\n###### *Example*\n\n~~~php\n$redis->setOption(Redis::OPT_MAX_RETRIES, 5);\n$redis->getOption(Redis::OPT_MAX_RETRIES);\n~~~\n\n#### Backoff algorithms\nYou can set the backoff algorithm using the `Redis::OPT_BACKOFF_ALGORITHM` option and choose among the following algorithms described in this blog post by Marc Brooker from AWS: [Exponential Backoff And Jitter](https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Farchitecture\u002Fexponential-backoff-and-jitter):\n\n* Default: `Redis::BACKOFF_ALGORITHM_DEFAULT`\n* Decorrelated jitter: `Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER`\n* Full jitter: `Redis::BACKOFF_ALGORITHM_FULL_JITTER`\n* Equal jitter: `Redis::BACKOFF_ALGORITHM_EQUAL_JITTER`\n* Exponential: `Redis::BACKOFF_ALGORITHM_EXPONENTIAL`\n* Uniform: `Redis::BACKOFF_ALGORITHM_UNIFORM`\n* Constant: `Redis::BACKOFF_ALGORITHM_CONSTANT`\n\nThese algorithms depend on the _base_ and _cap_ parameters, both in milliseconds, which you can set using the `Redis::OPT_BACKOFF_BASE` and `Redis::OPT_BACKOFF_CAP` options, respectively.\n\n###### *Example*\n\n~~~php\n$redis->setOption(Redis::OPT_BACKOFF_ALGORITHM, Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER);\n$redis->setOption(Redis::OPT_BACKOFF_BASE, 500); \u002F\u002F base for backoff computation: 500ms\n$redis->setOption(Redis::OPT_BACKOFF_CAP, 750); \u002F\u002F backoff time capped at 750ms\n~~~\n\n### Server\n\n1. [acl](#acl) - Manage Redis ACLs\n1. [bgRewriteAOF](#bgrewriteaof) - Asynchronously rewrite the append-only file\n1. [bgSave](#bgsave) - Asynchronously save the dataset to disk (in background)\n1. [config](#config) - Get or Set the Redis server configuration parameters\n1. [dbSize](#dbsize) - Return the number of keys in selected database\n1. [flushAll](#flushall) - Remove all keys from all databases\n1. [flushDb](#flushdb) - Remove all keys from the current database\n1. [info](#info) - Get information and statistics about the server\n1. [lastSave](#lastsave) - Get the timestamp of the last disk save\n1. [save](#save) - Synchronously save the dataset to disk (wait to complete)\n1. [wait](#wait) - Block until write acknowledgements from replicas\n1. [waitaof](#waitaof) - Wait for local AOF fsync and replica acknowledgements\n1. [slaveOf](#slaveof) - Make the server a slave of another instance, or promote it to master\n1. [time](#time) - Return the current server time\n1. [slowLog](#slowlog) - Access the Redis slowLog entries\n\n#### acl\n-----\n_**Description**_: Execute the Redis ACL command.\n\n###### *Parameters*\n_variable_:  Minimum of one argument for `Redis` and two for `RedisCluster`.\n\n###### *Example*\n~~~php\n$redis->acl('USERS'); \u002F* Get a list of users *\u002F\n$redis->acl('LOG');   \u002F* See log of Redis' ACL subsystem *\u002F\n~~~\n\n*Note*: In order to use the `ACL` 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](https:\u002F\u002Fredis.io\u002Ftopics\u002Facl) for an overview of Redis 6 ACLs and [the redis command reference](https:\u002F\u002Fredis.io\u002Fcommands) for every ACL subcommand.\n\n*Note*: If you are connecting to Redis server >= 4.0.0 you can remove a key with the `unlink` method in the exact same way you would use `del`.  The Redis [unlink](https:\u002F\u002Fredis.io\u002Fcommands\u002Funlink) command is non-blocking and will perform the actual deletion asynchronously.\n\n#### bgRewriteAOF\n-----\n_**Description**_: Start the background rewrite of AOF (Append-Only File)\n\n###### *Parameters*\nNone.\n\n###### *Return value*\n*BOOL*: `TRUE` in case of success, `FALSE` in case of failure.\n\n###### *Example*\n~~~php\n$redis->bgRewriteAOF();\n~~~\n\n#### bgSave\n-----\n_**Description**_: Asynchronously save the dataset to disk (in background)\n\n###### *Parameters*\nNone.\n\n###### *Return value*\n*BOOL*: `TRUE` in case of success, `FALSE` in case of failure. If a save is already running, this command will fail and return `FALSE`.\n\n###### *Example*\n~~~php\n$redis->bgSave();\n~~~\n\n#### config\n-----\n_**Description**_: Get or Set the Redis server configuration parameters.\n\n###### *Prototype*\n~~~php\n$redis->config(string $operation, string|array|null $key = NULL, ?string $value = NULL): mixed;\n~~~\n\n###### *Return value*\n*Associative array* for `GET`, key(s) -> value(s)\n*bool* for `SET`, `RESETSTAT`, and `REWRITE`\n\n###### *Examples*\n~~~php\n$redis->config(\"GET\", \"*max-*-entries*\");\n$redis->config(\"SET\", ['timeout', 'loglevel']);\n$redis->config(\"SET\", \"dir\", \"\u002Fvar\u002Frun\u002Fredis\u002Fdumps\u002F\");\n$redis->config(\"SET\", ['timeout' => 128, 'loglevel' => 'warning']);\n$redis->config('RESETSTAT');\n~~~\n\n#### dbSize\n-----\n_**Description**_: Return the number of keys in selected database.\n\n###### *Parameters*\nNone.\n\n###### *Return value*\n*INTEGER*: DB size, in number of keys.\n\n###### *Example*\n~~~php\n$count = $redis->dbSize();\necho \"Redis has $count keys\\n\";\n~~~\n\n#### flushAll\n-----\n_**Description**_: Remove all keys from all databases.\n\n###### *Parameters*\n*async* (bool) requires server version 4.0.0 or greater\n\n###### *Return value*\n*BOOL*: Always `TRUE`.\n\n###### *Example*\n~~~php\n$redis->flushAll();\n~~~\n\n#### flushDb\n-----\n_**Description**_: Remove all keys from the current database.\n\n###### *Prototype*\n~~~php\n$redis->flushdb(?bool $sync = NULL): Redis|bool;\n~~~\n\n###### *Return value*\n*BOOL*:  This command returns true on success and false on failure.\n\n###### *Example*\n~~~php\n$redis->flushDb();\n~~~\n\n#### info\n-----\n_**Description**_: Get information and statistics about the server\n\nReturns an associative array that provides information about the server. Passing no arguments to\nINFO will call the standard REDIS INFO command, which returns information such as the following:\n\n* redis_version\n* arch_bits\n* uptime_in_seconds\n* uptime_in_days\n* connected_clients\n* connected_slaves\n* used_memory\n* changes_since_last_save\n* bgsave_in_progress\n* last_save_time\n* total_connections_received\n* total_commands_processed\n* role\n\nYou can pass a variety of options to INFO ([per the Redis documentation](http:\u002F\u002Fredis.io\u002Fcommands\u002Finfo)),\nwhich will modify what is returned.\n\n###### *Parameters*\n*option*: The option to provide redis (e.g. \"COMMANDSTATS\", \"CPU\")\n\n###### *Example*\n~~~php\n$redis->info(); \u002F* standard redis INFO command *\u002F\n$redis->info(\"COMMANDSTATS\"); \u002F* Information on the commands that have been run (>=2.6 only)\n$redis->info(\"CPU\"); \u002F* just CPU information from Redis INFO *\u002F\n~~~\n\n#### lastSave\n-----\n_**Description**_: Returns the timestamp of the last disk save.\n\n###### *Parameters*\nNone.\n\n###### *Return value*\n*INT*: timestamp.\n\n###### *Example*\n~~~php\n$redis->lastSave();\n~~~\n\n#### save\n-----\n_**Description**_: Synchronously save the dataset to disk (wait to complete)\n\n###### *Parameters*\nNone.\n\n###### *Return value*\n*BOOL*: `TRUE` in case of success, `FALSE` in case of failure. If a save is already running, this command will fail and return `FALSE`.\n\n###### *Example*\n~~~php\n$redis->save();\n~~~\n\n#### wait\n-----\n_**Description**_: Block the client until a specified number of replicas acknowledge the most recent write or until the timeout elapses.\n\n###### *Parameters*\n*numreplicas* (int): The number of replicas that must confirm the write.\n*timeout* (int): Maximum time to wait in milliseconds (`0` to wait indefinitely).\n\n###### *Return value*\n*INT*: The number of replicas that acknowledged the write before timing out, or `FALSE` on error.\n\n###### *Example*\n~~~php\n$redis->set('user:1', 'marco');\n$confirmed = $redis->wait(1, 500);\n\nif ($confirmed \u003C 1) {\n    \u002F\u002F Handle the case where the write was not replicated in time.\n}\n~~~\n\n#### waitaof\n-----\n_**Description**_: Block until Redis has durably written recent changes to the local AOF file the requested number of times and received acknowledgements from the requested number of replicas (Redis >= 7.2).\n\n###### *Parameters*\n*numlocal* (int): Minimum number of local AOF fsync operations to wait for.\n*numreplicas* (int): Number of replicas that must acknowledge the write.\n*timeout* (int): Maximum time to wait in milliseconds (`0` to wait indefinitely).\n\n###### *Return value*\n*ARRAY*: Two integers, where element `0` is the number of local fsync operations performed and element `1` is the number of replica acknowledgements, or `FALSE` on error.\n\n###### *Example*\n~~~php\n[$local, $replicas] = $redis->waitaof(1, 1, 1000);\n\nif ($local \u003C 1 || $replicas \u003C 1) {\n    \u002F\u002F The write was not persisted or replicated as requested.\n}\n~~~\n\n#### slaveOf\n-----\n_**Description**_: Changes the slave status\n\n###### *Parameters*\nEither host (string) and port (int), or no parameter to stop being a slave.\n\n###### *Return value*\n*BOOL*: `TRUE` in case of success, `FALSE` in case of failure.\n\n###### *Example*\n~~~php\n$redis->slaveOf('10.0.1.7', 6379);\n\u002F* ... *\u002F\n$redis->slaveOf();\n~~~\n\n#### time\n-----\n_**Description**_: Return the current server time.\n\n###### *Parameters*\n(none)\n\n###### *Return value*\nIf successful, the time will come back as an associative array with element zero being\nthe unix timestamp, and element one being microseconds.\n\n###### *Examples*\n~~~php\n$redis->time();\n~~~\n\n#### slowLog\n-----\n_**Description**_: Access the Redis slowLog\n\n###### *Parameters*\n*Operation* (string): This can be either `GET`, `LEN`, or `RESET`\n*Length* (integer), optional: If executing a `SLOWLOG GET` command, you can pass an optional length.\n#####\n\n###### *Return value*\nThe return value of SLOWLOG will depend on which operation was performed.\nSLOWLOG GET: Array of slowLog entries, as provided by Redis\nSLOGLOG LEN: Integer, the length of the slowLog\nSLOWLOG RESET: Boolean, depending on success\n#####\n\n###### *Examples*\n~~~php\n\u002F\u002F Get ten slowLog entries\n$redis->slowLog('get', 10);\n\u002F\u002F Get the default number of slowLog entries\n\n$redis->slowLog('get');\n\u002F\u002F Reset our slowLog\n$redis->slowLog('reset');\n\n\u002F\u002F Retrieve slowLog length\n$redis->slowLog('len');\n~~~\n\n### Keys and Strings\n\n#### Strings\n-----\n\n* [append](#append) - Append a value to a key\n* [bitCount](#bitcount) - Count set bits in a string\n* [bitOp](#bitop) - Perform bitwise operations between strings\n* [decr, decrBy](#decr-decrby) - Decrement the value of a key\n* [get](#get) - Get the value of a key\n* [getEx](#getex) - Get the value of a key and set its expiration\n* [getBit](#getbit) - Returns the bit value at offset in the string value stored at key\n* [getRange](#getrange) - Get a substring of the string stored at a key\n* [getSet](#getset) - Set the string value of a key and return its old value\n* [incr, incrBy](#incr-incrby) - Increment the value of a key\n* [incrByFloat](#incrbyfloat) - Increment the float value of a key by the given amount\n* [mGet](#mget) - Get the values of all the given keys\n* [mSet, mSetNX](#mset-msetnx) - Set multiple keys to multiple values\n* [set](#set) - Set the string value of a key\n* [setBit](#setbit) - Sets or clears the bit at offset in the string value stored at key\n* [setEx, pSetEx](#setex-psetex) - Set the value and expiration of a key\n* [setNx](#setnx) - Set the value of a key, only if the key does not exist\n* [setRange](#setrange) - Overwrite part of a string at key starting at the specified offset\n* [strLen](#strlen) - Get the length of the value stored in a key\n\n#### Keys\n-----\n\n* [del, delete, unlink](#del-delete-unlink) - Delete a key\n* [dump](#dump) - Return a serialized version of the value stored at the specified key.\n* [exists](#exists) - Determine if a key exists\n* [expire, pexpire](#expire-pexpire) - Set a key's time to live in seconds\n* [expireAt, pexpireAt](#expireat-pexpireat) - Set the expiration for a key as a UNIX timestamp\n* [keys](#keys-1) - Find all keys matching the given pattern\n* [scan](#scan) - Scan for keys in the keyspace (Redis >= 2.8.0)\n* [migrate](#migrate) - Atomically transfer a key from a Redis instance to another one\n* [move](#move) - Move a key to another database\n* [object](#object) - Inspect the internals of Redis objects\n* [persist](#persist) - Remove the expiration from a key\n* [randomKey](#randomkey) - Return a random key from the keyspace\n* [rename](#rename) - Rename a key\n* [renameNx](#renamenx) - Rename a key, only if the new key does not exist\n* [type](#type) - Determine the type stored at key\n* [sort](#sort) - Sort the elements in a list, set or sorted set\n* [ttl, pttl](#ttl-pttl) - Get the time to live for a key\n* [restore](#restore) - Create a key using the provided serialized value, previously obtained with [dump](#dump).\n\n-----\n\n#### get\n-----\n_**Description**_: Get the value related to the specified key\n\n###### *Parameters*\n*key*\n\n###### *Return value*\n*String* or *Bool*: If key doesn't exist, `FALSE` is returned. Otherwise, the value related to this key is returned.\n\n###### *Examples*\n\n~~~php\n$redis->get('key');\n~~~\n\n#### getEx\n-----\n_**Description**_: Get the value related to the specified key and set its expiration\n\n###### *Parameters*\n*key*\n*options array* (optional) with the following keys:\n  * `EX` - expire time in seconds\n  * `PX` - expire time in milliseconds\n  * `EXAT` - expire time in seconds since UNIX epoch\n  * `PXAT` - expire time in milliseconds since UNIX epoch\n  * `PERSIST` - remove the expiration from the key\n\n###### *Return value*\n*String* or *Bool*: If key doesn't exist, `FALSE` is returned. Otherwise, the value related to this key is returned.\n\n###### *Examples*\n\n~~~php\n$redis->getEx('key', ['EX' => 10]); \u002F\u002F get key and set its expiration to 10 seconds\n~~~\n\n#### set\n-----\n_**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\n\n###### *Parameters*\n*Key*\n*Value*\n*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\n\n###### *Return value*\n*Bool* `TRUE` if the command is successful.\n\n###### *Examples*\n~~~php\n\u002F\u002F Simple key -> value set\n$redis->set('key', 'value');\n\n\u002F\u002F Will redirect, and actually make an SETEX call\n$redis->set('key','value', 10);\n\n\u002F\u002F Will set the key, if it doesn't exist, with a ttl of 10 seconds\n$redis->set('key', 'value', ['nx', 'ex'=>10]);\n\n\u002F\u002F Will set a key, if it does exist, with a ttl of 1000 milliseconds\n$redis->set('key', 'value', ['xx', 'px'=>1000]);\n\n~~~\n\n#### setEx, pSetEx\n-----\n_**Description**_: Set the string value in argument as value of the key, with a time to live. PSETEX uses a TTL in milliseconds.\n\n###### *Parameters*\n*Key*\n*TTL*\n*Value*\n\n###### *Return value*\n*Bool* `TRUE` if the command is successful, `FALSE` in case of failure.\n\n###### *Examples*\n\n~~~php\n$redis->setEx('key', 3600, 'value'); \u002F\u002F sets key → value, with 1h TTL.\n$redis->pSetEx('key', 100, 'value'); \u002F\u002F sets key → value, with 0.1 sec TTL.\n~~~\n\n#### setNx\n-----\n_**Description**_: Set the string value in argument as value of the key if the key doesn't already exist in the database.\n\n###### *Parameters*\n*Key*\n*Value*\n\n###### *Return value*\n*Bool* `TRUE` if the command is successful, `FALSE` in case of failure.\n\n###### *Examples*\n~~~php\n$redis->setNx('key', 'value'); \u002F* return TRUE *\u002F\n$redis->setNx('key', 'value'); \u002F* return FALSE *\u002F\n~~~\n\n#### del, delete, unlink\n-----\n_**Description**_: Remove specified keys.\n\n###### *Parameters*\nAn array of keys, or an undefined number of parameters, each a key: *key1* *key2* *key3* ... *keyN*\n\n*Note*: If you are connecting to Redis server >= 4.0.0 you can remove a key with the `unlink` method in the exact same way you would use `del`.  The Redis [unlink](https:\u002F\u002Fredis.io\u002Fcommands\u002Funlink) command is non-blocking and will perform the actual deletion asynchronously.\n\n###### *Return value*\n*Long* Number of keys deleted (`0` if none existed to start with), `FALSE` in case of unexpected failure (i.e. connection, etc.)\n\n###### *Examples*\n~~~php\n$redis->set('key1', 'val1');\n$redis->set('key2', 'val2');\n$redis->set('key3', 'val3');\n$redis->set('key4', 'val4');\n\n$redis->del('key1', 'key2'); \u002F* return 2 *\u002F\n$redis->del(['key3', 'key4']); \u002F* return 2 *\u002F\n\n\u002F* If using Redis >= 4.0.0 you can call unlink *\u002F\n$redis->unlink('key1', 'key2');\n$redis->unlink(['key1', 'key2']);\n~~~\n\n**Note:** `delete` is an alias for `del` and will be removed in future versions of phpredis.\n\n#### exists\n-----\n_**Description**_: Verify if the specified key exists.\n\n###### *Parameters*\n*key*\n\n###### *Return value*\n*Long* Number of keys tested that exist (`0` if none do), `FALSE` in case of failure.\n\n###### *Examples*\n~~~php\n$redis->set('key', 'value');\n$redis->exists('key'); \u002F* 1 *\u002F\n$redis->exists('NonExistingKey'); \u002F* 0 *\u002F\n\n$redis->mset(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']);\n$redis->exists(['foo', 'bar', 'baz']); \u002F* 3 *\u002F\n$redis->exists('foo', 'bar', 'baz'); \u002F* 3 *\u002F\n~~~\n\n**Note**: This function took a single argument and returned TRUE or FALSE \u003Cv4.0.0.\n\n#### incr, incrBy\n-----\n_**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.\n\n###### *Parameters*\n*key*\n*value*: value that will be added to key (only for incrBy)\n\n###### *Return value*\n*INT* the new value\n\n###### *Examples*\n~~~php\n$redis->incr('key1'); \u002F* key1 didn't exists, set to 0 before the increment *\u002F\n\t\t\t\t\t  \u002F* and now has the value 1  *\u002F\n\n$redis->incr('key1'); \u002F* 2 *\u002F\n$redis->incr('key1'); \u002F* 3 *\u002F\n$redis->incr('key1'); \u002F* 4 *\u002F\n\n\u002F\u002F Will redirect, and actually make an INCRBY call\n$redis->incr('key1', 10);   \u002F* 14 *\u002F\n\n$redis->incrBy('key1', 10); \u002F* 24 *\u002F\n~~~\n\n#### incrByFloat\n-----\n_**Description**_: Increment the key with floating point precision.\n\n###### *Parameters*\n*key*\n*value*: (float) value that will be added to the key\n\n###### *Return value*\n*FLOAT* the new value\n\n###### *Examples*\n~~~php\n$redis->incrByFloat('key1', 1.5); \u002F* key1 didn't exist, so it will now be 1.5 *\u002F\n\n\n$redis->incrByFloat('key1', 1.5); \u002F* 3 *\u002F\n$redis->incrByFloat('key1', -1.5); \u002F* 1.5 *\u002F\n$redis->incrByFloat('key1', 2.5); \u002F* 4 *\u002F\n~~~\n\n#### decr, decrBy\n-----\n_**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.\n\n###### *Parameters*\n*key*\n*value*: value that will be subtracted to key (only for decrBy)\n\n###### *Return value*\n*INT* the new value\n\n###### *Examples*\n~~~php\n$redis->decr('key1'); \u002F* key1 didn't exists, set to 0 before the increment *\u002F\n\t\t\t\t\t  \u002F* and now has the value -1  *\u002F\n\n$redis->decr('key1'); \u002F* -2 *\u002F\n$redis->decr('key1'); \u002F* -3 *\u002F\n\n\u002F\u002F Will redirect, and actually make an DECRBY call\n$redis->decr('key1', 10);   \u002F* -13 *\u002F\n\n$redis->decrBy('key1', 10); \u002F* -23 *\u002F\n~~~\n\n#### mGet\n-----\n_**Description**_: Get the values of all the specified keys. If one or more keys don't exist, the array will contain `FALSE` at the position of the key.\n\n###### *Parameters*\n*Array*: Array containing the list of the keys\n\n###### *Return value*\n*Array*: Array containing the values related to keys in argument\n\n###### *Examples*\n~~~php\n$redis->set('key1', 'value1');\n$redis->set('key2', 'value2');\n$redis->set('key3', 'value3');\n$redis->mGet(['key1', 'key2', 'key3']); \u002F* ['value1', 'value2', 'value3'];\n$redis->mGet(['key0', 'key1', 'key5']); \u002F* [`FALSE`, 'value1', `FALSE`];\n~~~\n\n#### getSet\n-----\n_**Description**_: Sets a value and returns the previous entry at that key.\n###### *Parameters*\n*Key*: key\n\n*STRING*: value\n\n###### *Return value*\nA string, the previous value located at this key.\n###### *Example*\n~~~php\n$redis->set('x', '42');\n$exValue = $redis->getSet('x', 'lol');\t\u002F\u002F return '42', replaces x by 'lol'\n$newValue = $redis->get('x');\t\t\u002F\u002F return 'lol'\n~~~\n\n#### randomKey\n-----\n_**Description**_: Returns a random key.\n\n###### *Parameters*\nNone.\n###### *Return value*\n*STRING*: an existing key in redis.\n\n###### *Example*\n~~~php\n$key = $redis->randomKey();\n$surprise = $redis->get($key);\t\u002F\u002F who knows what's in there.\n~~~\n\n#### move\n-----\n_**Description**_: Moves a key to a different database.\n\n###### *Parameters*\n*Key*: key, the key to move.\n\n*INTEGER*: dbindex, the database number to move the key to.\n\n###### *Return value*\n*BOOL*: `TRUE` in case of success, `FALSE` in case of failure.\n###### *Example*\n\n~~~php\n$redis->select(0);\t\u002F\u002F switch to DB 0\n$redis->set('x', '42');\t\u002F\u002F write 42 to x\n$redis->move('x', 1);\t\u002F\u002F move to DB 1\n$redis->select(1);\t\u002F\u002F switch to DB 1\n$redis->get('x');\t\u002F\u002F will return 42\n~~~\n\n#### rename\n-----\n_**Description**_: Renames a key.\n###### *Parameters*\n*STRING*: srckey, the key to rename.\n\n*STRING*: dstkey, the new name for the key.\n\n###### *Return value*\n*BOOL*: `TRUE` in case of success, `FALSE` in case of failure.\n###### *Example*\n~~~php\n$redis->set('x', '42');\n$redis->rename('x', 'y');\n$redis->get('y'); \t\u002F\u002F → 42\n$redis->get('x'); \t\u002F\u002F → `FALSE`\n~~~\n\n#### renameNx\n-----\n_**Description**_: Same as rename, but will not replace a key if the destination already exists. This is the same behaviour as setNx.\n\n#### expire, pexpire\n-----\n_**Description**_: Sets an expiration on a key in either seconds or milliseconds.\n\n###### *Prototype*\n~~~php\npublic function expire(string $key, int $seconds, ?string $mode = NULL): Redis|bool;\npublic function pexpire(string $key, int $milliseconds, ?string $mode = NULL): Redis|bool;\n~~~\n\n###### *Return value*\n*BOOL*: `TRUE` if an expiration was set, and `FALSE` on failure or if one was not set.  You can distinguish between an error and an expiration not being set by checking `getLastError()`.\n###### *Example*\n~~~php\n$redis->set('x', '42');\n$redis->expire('x', 3);\t\u002F\u002F x will disappear in 3 seconds.\nsleep(5);\t\t\t\t\u002F\u002F wait 5 seconds\n$redis->get('x'); \t\t\u002F\u002F will return `FALSE`, as 'x' has expired.\n~~~\n\n#### expireAt, pexpireAt\n-----\n_**Description**_: Set a specific timestamp for a key to expire in seconds or milliseconds.\n\n###### *Prototype*\n~~~php\npublic function expireat(string $key, int $unix_timestamp, ?string $mode = NULL): Redis|bool;\npublic function pexpireat(string $key, int $unix_timestamp_millis, ?string $mode = NULL): Redis|bool;\n~~~\n\n###### *Return value*\n*BOOL*: `TRUE` if an expiration was set and `FALSE` if one was not set or in the event of an error. You can detect an actual error by checking `getLastError()`.\n\n###### *Example*\n~~~php\n$redis->set('x', '42');\n$redis->expireAt('x', time(NULL) + 3); \u002F\u002F x will disappear in 3 seconds.\nsleep(5);\t\t\t\t\u002F\u002F wait 5 seconds\n$redis->get('x'); \t\u002F\u002F will return `FALSE`, as 'x' has expired.\n~~~\n\n#### keys\n-----\n_**Description**_: Returns the keys that match a certain pattern.\n\n###### *Parameters*\n*STRING*: pattern, using '*' as a wildcard.\n\n###### *Return value*\n*Array of STRING*: The keys that match a certain pattern.\n\n###### *Example*\n~~~php\n$allKeys = $redis->keys('*');\t\u002F\u002F all keys will match this.\n$keyWithUserPrefix = $redis->keys('user*');\n~~~\n\n#### scan\n-----\n_**Description**_:  Scan the keyspace for keys\n\n###### *Parameters*\n*LONG (reference)*:  Iterator, initialized to NULL\n*STRING, Optional*:  Pattern to match\n*LONG, Optional*: Count of keys per iteration (only a suggestion to Redis)\n\n###### *Return value*\n*Array, boolean*:  This function will return an array of keys or FALSE if Redis returns zero keys\n\n*Note*: SCAN is a \"directed node\" command in [RedisCluster](cluster.md#directed-node-commands)\n\n###### *Example*\n~~~php\n\n\u002F* Without enabling Redis::SCAN_RETRY (default condition) *\u002F\n$it = NULL;\ndo {\n    \u002F\u002F Scan for some keys\n    $arr_keys = $redis->scan($it);\n\n    \u002F\u002F Redis may return empty results, so protect against that\n    if ($arr_keys !== FALSE) {\n        foreach($arr_keys as $str_key) {\n            echo \"Here is a key: $str_key\\n\";\n        }\n    }\n} while ($it > 0);\necho \"No more keys to scan!\\n\";\n\n\u002F* With Redis::SCAN_RETRY enabled *\u002F\n$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY);\n$it = NULL;\n\n\u002F* phpredis will retry the SCAN command if empty results are returned from the\n   server, so no empty results check is required. *\u002F\nwhile ($arr_keys = $redis->scan($it)) {\n    foreach ($arr_keys as $str_key) {\n        echo \"Here is a key: $str_key\\n\";\n    }\n}\necho \"No more keys to scan!\\n\";\n~~~\n\n#### object\n-----\n_**Description**_: Describes the object pointed to by a key.\n\n###### *Parameters*\nThe information to retrieve (string) and the key (string). Info can be one of the following:\n\n* \"encoding\"\n* \"refcount\"\n* \"idletime\"\n\n###### *Return value*\n*STRING* for \"encoding\", *LONG* for \"refcount\" and \"idletime\", `FALSE` if the key doesn't exist.\n\n###### *Example*\n~~~php\n$redis->object(\"encoding\", \"l\"); \u002F\u002F → ziplist\n$redis->object(\"refcount\", \"l\"); \u002F\u002F → 1\n$redis->object(\"idletime\", \"l\"); \u002F\u002F → 400 (in seconds, with a precision of 10 seconds).\n~~~\n\n#### type\n-----\n_**Description**_: Returns the type of data pointed by a given key.\n\n###### *Parameters*\n*Key*: key\n\n###### *Return value*\n\nDepending on the type of the data pointed by the key, this method will return the following value:\nstring: Redis::REDIS_STRING\nset: Redis::REDIS_SET\nlist: Redis::REDIS_LIST\nzset: Redis::REDIS_ZSET\nhash: Redis::REDIS_HASH\nother: Redis::REDIS_NOT_FOUND\n\n###### *Example*\n~~~php\n$redis->type('key');\n~~~\n\n#### append\n-----\n_**Description**_: Append specified string to the string stored in specified key.\n\n###### *Parameters*\n*Key*\n*Value*\n\n###### *Return value*\n*INTEGER*: Size of the value after the append\n\n###### *Example*\n~~~php\n$redis->set('key', 'value1');\n$redis->append('key', 'value2'); \u002F* 12 *\u002F\n$redis->get('key'); \u002F* 'value1value2' *\u002F\n~~~\n\n#### getRange\n-----\n_**Description**_: Return a substring of a larger string\n\n###### *Parameters*\n*key*\n*start*\n*end*\n\n###### *Return value*\n*STRING*: the substring\n\n###### *Example*\n~~~php\n$redis->set('key', 'string value');\n$redis->getRange('key', 0, 5); \u002F* 'string' *\u002F\n$redis->getRange('key', -5, -1); \u002F* 'value' *\u002F\n~~~\n\n#### setRange\n-----\n_**Description**_: Changes a substring of a larger string.\n\n###### *Parameters*\n*key*\n*offset*\n*value*\n\n###### *Return value*\n*STRING*: the length of the string after it was modified.\n\n###### *Example*\n~~~php\n$redis->set('key', 'Hello world');\n$redis->setRange('key', 6, \"redis\"); \u002F* returns 11 *\u002F\n$redis->get('key'); \u002F* \"Hello redis\" *\u002F\n~~~\n\n#### strLen\n-----\n_**Description**_: Get the length of a string value.\n\n###### *Parameters*\n*key*\n\n###### *Return value*\n*INTEGER*\n\n###### *Example*\n~~~php\n$redis->set('key', 'value');\n$redis->strlen('key'); \u002F* 5 *\u002F\n~~~\n\n#### getBit\n-----\n_**Description**_: Return a single bit out of a larger string\n\n###### *Parameters*\n*key*\n*offset*\n\n###### *Return value*\n*LONG*: the bit value (0 or 1)\n\n###### *Example*\n~~~php\n$redis->set('key', \"\\x7f\"); \u002F\u002F this is 0111 1111\n$redis->getBit('key', 0); \u002F* 0 *\u002F\n$redis->getBit('key', 1); \u002F* 1 *\u002F\n~~~\n\n#### setBit\n-----\n_**Description**_: Changes a single bit of a string.\n\n###### *Parameters*\n*key*\n*offset*\n*value*: bool or int (1 or 0)\n\n###### *Return value*\n*LONG*: 0 or 1, the value of the bit before it was set.\n\n###### *Example*\n~~~php\n$redis->set('key', \"*\");\t\u002F\u002F ord(\"*\") = 42 = 0x2f = \"0010 1010\"\n$redis->setBit('key', 5, 1); \u002F* returns 0 *\u002F\n$redis->setBit('key', 7, 1); \u002F* returns 0 *\u002F\n$redis->get('key'); \u002F* chr(0x2f) = \"\u002F\" = b(\"0010 1111\") *\u002F\n~~~\n\n#### bitOp\n-----\n_**Description**_: Bitwise operation on multiple keys.\n\n###### *Parameters*\n*operation*: either \"AND\", \"OR\", \"NOT\", \"XOR\"\n*ret_key*: return key\n*key1*\n*key2...*\n\n###### *Return value*\n*LONG*: The size of the string stored in the destination key.\n\n#### bitCount\n-----\n_**Description**_: Count bits in a string.\n\n###### *Parameters*\n*key*\n\n###### *Return value*\n*LONG*: The number of bits set to 1 in the value behind the input key.\n\n#### sort\n-----\n_**Description**_: Sort the elements in a list, set or sorted set.\n\n###### *Parameters*\n*Key*: key\n*Options*: [key => value, ...] - optional, with the following keys and values:\n~~~\n    'by' => 'some_pattern_*',\n    'limit' => [0, 1],\n    'get' => 'some_other_pattern_*' or an array of patterns,\n    'sort' => 'asc' or 'desc',\n    'alpha' => TRUE,\n    'store' => 'external-key'\n~~~\n###### *Return value*\nAn array of values, or a number corresponding to the number of elements stored if that was used.\n\n###### *Example*\n~~~php\n$redis->del('s');\n$redis->sAdd('s', 5);\n$redis->sAdd('s', 4);\n$redis->sAdd('s', 2);\n$redis->sAdd('s', 1);\n$redis->sAdd('s', 3);\n\nvar_dump($redis->sort('s')); \u002F\u002F 1,2,3,4,5\nvar_dump($redis->sort('s', ['sort' => 'desc'])); \u002F\u002F 5,4,3,2,1\nvar_dump($redis->sort('s', ['sort' => 'desc', 'store' => 'out'])); \u002F\u002F (int)5\n~~~\n\n\n\n\n#### ttl, pttl\n-----\n_**Description**_: Returns the time to live left for a given key in seconds (ttl), or milliseconds (pttl).\n\n###### *Parameters*\n*Key*: key\n\n###### *Return value*\n*LONG*: The time to live in seconds. If the key has no ttl, `-1` will be returned, and `-2` if the key doesn't exist.\n\n###### *Example*\n~~~php\n$redis->ttl('key');\n~~~\n\n#### persist\n-----\n_**Description**_: Remove the expiration timer from a key.\n\n###### *Parameters*\n*Key*: key\n\n###### *Return value*\n*BOOL*: `TRUE` if a timeout was removed, `FALSE` if the key didn’t exist or didn’t have an expiration timer.\n\n###### *Example*\n~~~php\n$redis->persist('key');\n~~~\n\n#### mSet, mSetNx\n-----\n_**Description**_: Sets multiple key-value pairs in one atomic command. MSETNX only returns TRUE if all the keys were set (see SETNX).\n\n###### *Parameters*\n*Pairs*: [key => value, ...]\n\n###### *Return value*\n*Bool* `TRUE` in case of success, `FALSE` in case of failure.\n\n###### *Example*\n~~~php\n\n$redis->mSet(['key0' => 'value0', 'key1' => 'value1']);\nvar_dump($redis->get('key0'));\nvar_dump($redis->get('key1'));\n\n~~~\nOutput:\n~~~\nstring(6) \"value0\"\nstring(6) \"value1\"\n~~~\n\n\n\n#### dump\n-----\n_**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\nthat comes out of DUMP is a binary representation of the key as Redis stores it.\n###### *Parameters*\n*key* string\n###### *Return value*\nThe Redis encoded value of the key, or FALSE if the key doesn't exist\n###### *Examples*\n~~~php\n$redis->set('foo', 'bar');\n$val = $redis->dump('foo'); \u002F\u002F $val will be the Redis encoded key value\n~~~\n\n#### restore\n-----\n_**Description**_: Restore a key from the result of a DUMP operation.\n###### *Parameters*\n*key* string.  The key name\n*ttl* integer.  How long the key should live (if zero, no expire will be set on the key)\n*value* string (binary).  The Redis encoded key value (from DUMP)\n###### *Examples*\n~~~php\n$redis->set('foo', 'bar');\n$val = $redis->dump('foo');\n$redis->restore('bar', 0, $val); \u002F\u002F The key 'bar', will now be equal to the key 'foo'\n~~~\n\n#### migrate\n-----\n_**Description**_: Migrates a key to a different Redis instance.\n\n**Note:**: Redis introduced migrating multiple keys in 3.0.6, so you must have at least\nthat version to call `migrate` with an array of keys.\n\n###### *Parameters*\n*host* string.  The destination host\n*port* integer.  The TCP port to connect to.\n*key(s)* string or array.\n*destination-db* integer.  The target DB.\n*timeout* integer.  The maximum amount of time given to this transfer.\n*copy* boolean, optional.  Should we send the COPY flag to redis.\n*replace* boolean, optional.  Should we send the REPLACE flag to redis\n###### *Examples*\n~~~php\n$redis->migrate('backup', 6379, 'foo', 0, 3600);\n$redis->migrate('backup', 6379, 'foo', 0, 3600, true, true); \u002F* copy and replace *\u002F\n$redis->migrate('backup', 6379, 'foo', 0, 3600, false, true); \u002F* just REPLACE flag *\u002F\n\n\u002F* Migrate multiple keys (requires Redis >= 3.0.6)\n$redis->migrate('backup', 6379, ['key1', 'key2', 'key3'], 0, 3600);\n~~~\n\n\n\n### Hashes\n\n* [hDel](#hdel) - Delete one or more hash fields\n* [hExists](#hexists) - Determine if a hash field exists\n* [hGet](#hget) - Get the value of a hash field\n* [hGetAll](#hgetall) - Get all the fields and values in a hash\n* [hIncrBy](#hincrby) - Increment the integer value of a hash field by the given number\n* [hIncrByFloat](#hincrbyfloat) - Increment the float value of a hash field by the given amount\n* [hKeys](#hkeys) - Get all the fields in a hash\n* [hLen](#hlen) - Get the number of fields in a hash\n* [hMGet](#hmget) - Get the values of all the given hash fields\n* [hMSet](#hmset) - Set multiple hash fields to multiple values\n* [hSet](#hset) - Set the string value of a hash field\n* [hSetNx](#hsetnx) - Set the value of a hash field, only if the field does not exist\n* [hVals](#hvals) - Get all the values in a hash\n* [hScan](#hscan) - Scan a hash key for members\n* [hStrLen](#hstrlen) - Get the string length of the value associated with field in the hash\n\n#### hSet\n-----\n_**Description**_: Adds a value to the hash stored at key.\n###### *Parameters*\n*key*\n*hashKey*\n*value*\n\n###### *Return value*\n*LONG* `1` if value didn't exist and was added successfully, `0` if the value was already present and was replaced, `FALSE` if there was an error.\n###### *Example*\n~~~php\n$redis->del('h')\n$redis->hSet('h', 'key1', 'hello'); \u002F* 1, 'key1' => 'hello' in the hash at \"h\" *\u002F\n$redis->hGet('h', 'key1'); \u002F* returns \"hello\" *\u002F\n\n$redis->hSet('h', 'key1', 'plop'); \u002F* 0, value was replaced. *\u002F\n$redis->hGet('h', 'key1'); \u002F* returns \"plop\" *\u002F\n~~~\n\n#### hSetNx\n-----\n_**Description**_: Adds a value to the hash stored at key only if this field isn't already in the hash.\n\n###### *Return value*\n*BOOL* `TRUE` if the field was set, `FALSE` if it was already present.\n\n###### *Example*\n~~~php\n$redis->del('h')\n$redis->hSetNx('h', 'key1', 'hello'); \u002F* TRUE, 'key1' => 'hello' in the hash at \"h\" *\u002F\n$redis->hSetNx('h', 'key1', 'world'); \u002F* FALSE, 'key1' => 'hello' in the hash at \"h\". No change since the field wasn't replaced. *\u002F\n~~~\n\n\n#### hGet\n-----\n_**Description**_: Gets a value from the hash stored at key. If the hash table doesn't exist, or the key doesn't exist, `FALSE` is returned.\n###### *Parameters*\n*key*\n*hashKey*\n\n###### *Return value*\n*STRING* The value, if the command executed successfully\n*BOOL* `FALSE` in case of failure\n\n\n#### hLen\n-----\n_**Description**_: Returns the length of a hash, in number of items\n###### *Parameters*\n*key*\n\n###### *Return value*\n*LONG* the number of items in a hash, `FALSE` if the key doesn't exist or isn't a hash.\n###### *Example*\n~~~php\n$redis->del('h')\n$redis->hSet('h', 'key1', 'hello');\n$redis->hSet('h', 'key2', 'plop');\n$redis->hLen('h'); \u002F* returns 2 *\u002F\n~~~\n\n#### hDel\n-----\n_**Description**_: Removes a value from the hash stored at key. If the hash table doesn't exist, or the key doesn't exist, `FALSE` is returned.\n###### *Parameters*\n*key*\n*hashKey1*\n*hashKey2*\n...\n\n###### *Return value*\n*LONG* the number of deleted keys, 0 if the key doesn't exist, `FALSE` if the key isn't a hash.\n\n\n#### hKeys\n-----\n_**Description**_: Returns the keys in a hash, as an array of strings.\n\n###### *Parameters*\n*Key*: key\n\n###### *Return value*\nAn array of elements, the keys of the hash. This works like PHP's array_keys().\n\n###### *Example*\n~~~php\n$redis->del('h');\n$redis->hSet('h', 'a', 'x');\n$redis->hSet('h', 'b', 'y');\n$redis->hSet('h', 'c', 'z');\n$redis->hSet('h', 'd', 't');\nvar_dump($redis->hKeys('h'));\n~~~\n\nOutput:\n~~~\narray(4) {\n  [0]=>\n  string(1) \"a\"\n  [1]=>\n  string(1) \"b\"\n  [2]=>\n  string(1) \"c\"\n  [3]=>\n  string(1) \"d\"\n}\n~~~\nThe order is random and corresponds to redis' own internal representation of the set structure.\n\n#### hVals\n-----\n_**Description**_: Returns the values in a hash, as an array of strings.\n\n###### *Parameters*\n*Key*: key\n\n###### *Return value*\nAn array of elements, the values of the hash. This works like PHP's array_values().\n\n###### *Example*\n~~~php\n$redis->del('h');\n$redis->hSet('h', 'a', 'x');\n$redis->hSet('h', 'b', 'y');\n$redis->hSet('h', 'c', 'z');\n$redis->hSet('h', 'd', 't');\nvar_dump($redis->hVals('h'));\n~~~\n\nOutput:\n~~~\narray(4) {\n  [0]=>\n  string(1) \"x\"\n  [1]=>\n  string(1) \"y\"\n  [2]=>\n  string(1) \"z\"\n  [3]=>\n  string(1) \"t\"\n}\n~~~\nThe order is random and corresponds to redis' own internal representation of the set structure.\n\n#### hGetAll\n-----\n_**Description**_: Returns the whole hash, as an array of strings indexed by strings.\n\n###### *Parameters*\n*Key*: key\n\n###### *Return value*\nAn array of elements, the contents of the hash.\n\n###### *Example*\n~~~php\n$redis->del('h');\n$redis->hSet('h', 'a', 'x');\n$redis->hSet('h', 'b', 'y');\n$redis->hSet('h', 'c', 'z');\n$redis->hSet('h', 'd', 't');\nvar_dump($redis->hGetAll('h'));\n~~~\n\nOutput:\n~~~\narray(4) {\n  [\"a\"]=>\n  string(1) \"x\"\n  [\"b\"]=>\n  string(1) \"y\"\n  [\"c\"]=>\n  string(1) \"z\"\n  [\"d\"]=>\n  string(1) \"t\"\n}\n~~~\nThe order is random and corresponds to redis' own internal representation of the set structure.\n\n#### hExists\n-----\n_**Description**_: Verify if the specified member exists in a key.\n###### *Parameters*\n*key*\n*memberKey*\n###### *Return value*\n*BOOL*: If the member exists in the hash table, return `TRUE`, otherwise return `FALSE`.\n###### *Examples*\n~~~php\n$redis->hSet('h', 'a', 'x');\n$redis->hExists('h', 'a'); \u002F*  TRUE *\u002F\n$redis->hExists('h', 'NonExistingKey'); \u002F* FALSE *\u002F\n~~~\n\n#### hIncrBy\n-----\n_**Description**_: Increments the value of a member from a hash by a given amount.\n###### *Parameters*\n*key*\n*member*\n*value*: (integer) value that will be added to the member's value\n###### *Return value*\n*LONG* the new value\n###### *Examples*\n~~~php\n$redis->del('h');\n$redis->hIncrBy('h', 'x', 2); \u002F* returns 2: h[x] = 2 now. *\u002F\n$redis->hIncrBy('h', 'x', 1); \u002F* h[x] ← 2 + 1. Returns 3 *\u002F\n~~~\n\n#### hIncrByFloat\n-----\n_**Description**_: Increments the value of a hash member by the provided float value\n###### *Parameters*\n*key*\n*member*\n*value*: (float) value that will be added to the member's value\n###### *Return value*\n*FLOAT* the new value\n###### *Examples*\n~~~php\n$redis->del('h');\n$redis->hIncrByFloat('h','x', 1.5); \u002F* returns 1.5: h[x] = 1.5 now *\u002F\n$redis->hIncrByFloat('h', 'x', 1.5); \u002F* returns 3.0: h[x] = 3.0 now *\u002F\n$redis->hIncrByFloat('h', 'x', -3.0); \u002F* returns 0.0: h[x] = 0.0 now *\u002F\n~~~\n\n#### hMSet\n-----\n_**Description**_: Fills in a whole hash. Non-string values are converted to string, using the standard `(string)` cast. NULL values are stored as empty strings.\n###### *Parameters*\n*key*\n*members*: key → value array\n###### *Return value*\n*BOOL*\n###### *Examples*\n~~~php\n$redis->del('user:1');\n$redis->hMSet('user:1', ['name' => 'Joe', 'salary' => 2000]);\n$redis->hIncrBy('user:1', 'salary', 100); \u002F\u002F Joe earns 100 more now.\n~~~\n\n#### hMGet\n-----\n_**Description**_: Retrieve the values associated to the specified fields in the hash.\n###### *Parameters*\n*key*\n*memberKeys* Array\n###### *Return value*\n*Array* An array of elements, the values of the specified fields in the hash, with the hash keys as array keys.\n###### *Examples*\n~~~php\n$redis->del('h');\n$redis->hSet('h', 'field1', 'value1');\n$redis->hSet('h', 'field2', 'value2');\n$redis->hMGet('h', ['field1', 'field2']); \u002F* returns ['field1' => 'value1', 'field2' => 'value2'] *\u002F\n~~~\n\n#### hScan\n-----\n_**Description**_:  Scan a HASH value for members, with an optional pattern and count\n###### *Parameters*\n*key*: String\n*iterator*: Long (reference)\n*pattern*: Optional pattern to match against\n*count*: How many keys to return in a go (only a suggestion to Redis)\n###### *Return value*\n*Array* An array of members that match our pattern\n\n###### *Examples*\n~~~php\n$it = NULL;\n\u002F* Don't ever return an empty array until we're done iterating *\u002F\n$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY);\nwhile($arr_keys = $redis->hScan('hash', $it)) {\n    foreach($arr_keys as $str_field => $str_value) {\n        echo \"$str_field => $str_value\\n\"; \u002F* Print the hash member and value *\u002F\n    }\n}\n~~~\n\n#### hStrLen\n-----\n_**Description**_: Get the string length of the value associated with field in the hash stored at key.\n###### *Parameters*\n*key*: String\n*field*: String\n###### *Return value*\n*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.\n\n### Lists\n\n* [blPop, brPop](#blpop-brpop) - Remove and get the first\u002Flast element in a list\n* [bRPopLPush](#brpoplpush) - Pop a value from a list, push it to another list and return it\n* [lIndex](#lindex) - Get an element from a list by its index\n* [lInsert](#linsert) - Insert an element before or after another element in a list\n* [lLen](#llen) - Get the length\u002Fsize of a list\n* [lPop](#lpop) - Remove and get the first element in a list\n* [lPush](#lpush) - Prepend one or multiple values to a list\n* [lPushx](#lpushx) - Prepend a value to a list, only if the list exists\n* [lRange](#lrange) - Get a range of elements from a list\n* [lRem](#lrem) - Remove elements from a list\n* [lSet](#lset) - Set the value of an element in a list by its index\n* [lTrim](#ltrim) - Trim a list to the specified range\n* [rPop](#rpop) - Remove and get the last element in a list\n* [rPopLPush](#rpoplpush) - Remove the last element in a list, append it to another list and return it (redis >= 1.1)\n* [rPush](#rpush) - Append one or multiple values to a list\n* [rPushX](#rpushx) - Append a value to a list, only if the list exists\n\n#### blPop, brPop\n-----\n_**Description**_: Is a blocking lPop(rPop) primitive. 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.\nIf 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.\n\n###### *Parameters*\n*ARRAY* Array containing the keys of the lists\n*INTEGER* Timeout\nOr\n*STRING* Key1\n*STRING* Key2\n*STRING* Key3\n...\n*STRING* Keyn\n*INTEGER* Timeout\n\n###### *Return value*\n*ARRAY* ['listName', 'element']\n\n###### *Example*\n~~~php\n\u002F* Non blocking feature *\u002F\n$redis->lPush('key1', 'A');\n$redis->del('key2');\n\n$redis->blPop('key1', 'key2', 10); \u002F* ['key1', 'A'] *\u002F\n\u002F* OR *\u002F\n$redis->blPop(['key1', 'key2'], 10); \u002F* ['key1', 'A'] *\u002F\n\n$redis->brPop('key1', 'key2', 10); \u002F* ['key1', 'A'] *\u002F\n\u002F* OR *\u002F\n$redis->brPop(['key1', 'key2'], 10); \u002F* ['key1', 'A'] *\u002F\n\n\u002F* Blocking feature *\u002F\n\n\u002F* process 1 *\u002F\n$redis->del('key1');\n$redis->blPop('key1', 10);\n\u002F* blocking for 10 seconds *\u002F\n\n\u002F* process 2 *\u002F\n$redis->lPush('key1', 'A');\n\n\u002F* process 1 *\u002F\n\u002F* ['key1', 'A'] is returned*\u002F\n~~~\n\n#### bRPopLPush\n-----\n_**Description**_: A blo","phpredis是一个用于与Redis键值存储进行通信的PHP扩展。它支持包括集群、Valkey和KeyDB在内的多种Redis功能，提供了高性能的数据存取能力，并且兼容PHP 7.4及以上版本。该扩展通过C语言实现，保证了操作效率和稳定性。适用于需要快速数据访问的应用场景，如缓存系统、消息队列服务等，尤其适合那些已经使用或计划采用Redis作为其后端存储解决方案的Web应用开发者。",2,"2026-06-11 03:06:08","top_language"]