{"id":21571157,"url":"https://github.com/cheprasov/php-redis-client","last_synced_at":"2025-04-04T20:14:33.766Z","repository":{"id":3612923,"uuid":"45416684","full_name":"cheprasov/php-redis-client","owner":"cheprasov","description":"RedisClient is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from 2.6 to 6.0","archived":false,"fork":false,"pushed_at":"2022-07-12T23:45:48.000Z","size":726,"stargazers_count":127,"open_issues_count":8,"forks_count":42,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-05-15T20:35:13.551Z","etag":null,"topics":["client","php","php-redis-client","redis","redis-client","redis-cluster"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cheprasov.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"cheprasov","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2015-11-02T19:26:27.000Z","updated_at":"2024-03-22T09:17:51.000Z","dependencies_parsed_at":"2022-08-26T13:30:46.499Z","dependency_job_id":null,"html_url":"https://github.com/cheprasov/php-redis-client","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheprasov%2Fphp-redis-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheprasov%2Fphp-redis-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheprasov%2Fphp-redis-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheprasov%2Fphp-redis-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cheprasov","download_url":"https://codeload.github.com/cheprasov/php-redis-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247242680,"owners_count":20907134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","php","php-redis-client","redis","redis-client","redis-cluster"],"created_at":"2024-11-24T11:15:04.838Z","updated_at":"2025-04-04T20:14:33.748Z","avatar_url":"https://github.com/cheprasov.png","language":"PHP","readme":"[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)\n[![Latest Stable Version](https://poser.pugx.org/cheprasov/php-redis-client/v/stable)](https://packagist.org/packages/cheprasov/php-redis-client)\n[![Total Downloads](https://poser.pugx.org/cheprasov/php-redis-client/downloads)](https://packagist.org/packages/cheprasov/php-redis-client)\n# RedisClient v1.10.0 for PHP \u003e= 5.5\n\n## About\nRedisClient is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from __2.6__ to __6.0__\n\n## Main features\n- Support Redis versions from __2.6.x__ to __6.0.x__.\n- Support __TCP/IP__ and __UNIX__ sockets.\n- Support __PubSub__ and __Monitor__ functionallity.\n- Support __Pipeline__ and __Transactions__.\n- Support __Redis Cluster__.\n- Support __RAW__ commands as arrays `['SET', 'foo', 'bar']`.\n- Connections to Redis are established lazily by the client upon the first command.\n- Easy to use with IDE, client has PHPDocs for all supported versions.\n- By default, the client works with the latest stable version of Redis (6.0).\n- The client was tested on the next latest versions of Redis: `6.0.5`, `5.0.5`, `4.0.14`, `3.2.8`, `3.0.7`, `2.8.24`, `2.6.17`.\n- Also, the client was tested on PHP `7.4`, `7.3`, `7.2`, `7.1`, `7.0`, `5.6`, `5.5`, `HHVM`.\n\n## Redis Commands\n\nPlease see list of commands here [./COMMANDS.md](https://github.com/cheprasov/php-redis-client/tree/master/COMMANDS.md)\n\n## Usage\n\n### Config\n\n```php\n$config = [\n    // Optional. Default = '127.0.0.1:6379'. You can use 'unix:///tmp/redis.sock'\n    'server' =\u003e '127.0.0.1:6379',\n\n    // Optional. Default = 1\n    // The timeout for reading/writing data over the socket\n    'timeout' =\u003e 2,\n\n    // Optional. Default = null\n    // See more here: http://php.net/manual/en/function.stream-socket-client.php\n    'connection' =\u003e [\n        // Optional. Default = ini_get(\"default_socket_timeout\")\n        // The timeout only applies while making connecting the socket\n        'timeout' =\u003e 2,\n\n        // Optional. Default = STREAM_CLIENT_CONNECT\n        // Bitmask field which may be set to any combination of connection flags.\n        // Currently the select of connection flags is limited to STREAM_CLIENT_CONNECT (default),\n        // STREAM_CLIENT_ASYNC_CONNECT and STREAM_CLIENT_PERSISTENT.\n        'flags' =\u003e STREAM_CLIENT_CONNECT\n    ],\n\n    // Optional. Specify version to avoid some unexpected errors.\n    'version' =\u003e '4.0.10',\n\n    // Optional. Use it only if Redis server requires password (AUTH)\n    'password' =\u003e 'some-password',\n\n    // Optional. Use it, if you want to select not default db (db != 0) on connect\n    'database' =\u003e 1,\n\n    // Optional. Array with configs for RedisCluster support\n    'cluster' =\u003e [\n        'enabled' =\u003e false,\n\n        // Optional. Default = []. Map of cluster slots and servers\n        // array(max_slot =\u003e server [, ...])\n        // Examples for Cluster with 3 Nodes:\n        'clusters' =\u003e [\n            5460  =\u003e '127.0.0.1:7001', // slots from 0 to 5460\n            10922 =\u003e '127.0.0.1:7002', // slots from 5461 to 10922\n            16383 =\u003e '127.0.0.1:7003', // slots from 10923 to 16383\n        ],\n\n        // Optional. Default = false.\n        // Use the param to update cluster slot map below on init RedisClient.\n        // RedisClient will execute command CLUSTER SLOTS to get map.\n        'init_on_start' =\u003e false,\n\n        // Optional. Default = false.\n        // If Redis returns error -MOVED then RedisClient will execute\n        // command CLUSTER SLOTS to update cluster slot map\n        'init_on_error_moved' =\u003e true,\n\n        // Optional. Defatult = 0.05 sec. It is timeout before next attempt on TRYAGAIN error.\n        'timeout_on_error_tryagain' =\u003e 0.25, // sec\n    ]\n];\n```\n\n### Create a new instance of RedisClient\n```php\n\u003c?php\nnamespace Examples;\n\nrequire (dirname(__DIR__).'/vendor/autoload.php');\n// or require (dirname(__DIR__).'/src/autoloader.php');\n\nuse RedisClient\\RedisClient;\nuse RedisClient\\Client\\Version\\RedisClient2x6;\nuse RedisClient\\ClientFactory;\n\n// Example 1. Create new Instance for Redis version 6.0.x with config via factory\n$Redis = ClientFactory::create([\n    'server' =\u003e '127.0.0.1:6379', // or 'unix:///tmp/redis.sock'\n    'timeout' =\u003e 2,\n    'version' =\u003e '6.0'\n]);\n\necho 'RedisClient: '. $Redis-\u003egetSupportedVersion() . PHP_EOL; // RedisClient: 2.8\n\n\n// Example 2. Create new Instance without config. Client will use default config.\n$Redis = new RedisClient();\n// By default, the client works with the latest stable version of Redis.\necho 'RedisClient: '. $Redis-\u003egetSupportedVersion() . PHP_EOL; // RedisClient: 3.2\necho 'Redis: '. $Redis-\u003einfo('Server')['redis_version'] . PHP_EOL; // Redis: 3.0.3\n\n\n// Example 3. Create new Instance with config\n// By default, the client works with the latest stable version of Redis.\n$Redis = new RedisClient([\n    'server' =\u003e '127.0.0.1:6387', // or 'unix:///tmp/redis.sock'\n    'timeout' =\u003e 2\n]);\n\necho 'RedisClient: '. $Redis-\u003egetSupportedVersion() . PHP_EOL; // RedisClient: 3.2\necho 'Redis: '. $Redis-\u003einfo('Server')['redis_version'] . PHP_EOL; // Redis: 3.2.0\n\n\n// Example 4. Create new Instance for Redis version 2.6.x with config\n$Redis = new RedisClient2x6([\n    'server' =\u003e 'tcp://127.0.0.1:6379', // or 'unix:///tmp/redis.sock'\n    'timeout' =\u003e 2\n]);\n\necho 'RedisClient: '. $Redis-\u003egetSupportedVersion() . PHP_EOL; // RedisClient: 2.6\n```\n\n### Example\nPlease, see examples here: https://github.com/cheprasov/php-redis-client/tree/master/examples\n\n- [Create new instance](https://github.com/cheprasov/php-redis-client/tree/master/examples/create_new_instance.php)\n- [Using MONITOR](https://github.com/cheprasov/php-redis-client/tree/master/examples/monitor.php)\n- [Publish and Subscribe](https://github.com/cheprasov/php-redis-client/tree/master/examples/pubsub.php)\n- [Transactions](https://github.com/cheprasov/php-redis-client/tree/master/examples/transactions.php)\n- [Pipeline](https://github.com/cheprasov/php-redis-client/tree/master/examples/pipeline.php)\n- [Cluster support](https://github.com/cheprasov/php-redis-client/tree/master/examples/clusters.php)\n- [RAW Commands](https://github.com/cheprasov/php-redis-client/tree/master/examples/raw_commands.php)\n\n## Installation\n\n### Composer\n\nDownload composer:\n\n    wget -nc http://getcomposer.org/composer.phar\n\nand add dependency to your project:\n\n    php composer.phar require cheprasov/php-redis-client\n\n## Running tests\n\n1. Run Docker container with Redis for tests https://hub.docker.com/r/cheprasov/redis-for-tests/\n2. Run Docker container with Redis Cluster for tests https://hub.docker.com/r/cheprasov/redis-cluster-for-tests/\n3. To run tests type in console:\n\n    ./vendor/bin/phpunit\n\n## Something doesn't work\n\nFeel free to fork project, fix bugs and finally request for pull\n","funding_links":["https://github.com/sponsors/cheprasov"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheprasov%2Fphp-redis-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheprasov%2Fphp-redis-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheprasov%2Fphp-redis-client/lists"}