clue/redis-react
Async Redis client for ReactPHP. Send commands in parallel with automatic pipelining and promise-based responses. Event-driven Pub/Sub support, lightweight SOLID design, and strong test coverage for Redis v2.6+.
Start by installing the package via Composer (composer require clue/redis-react) and importing the React\Redis\Client class. Initialize the client using Client::create('tcp://127.0.0.1:6379'), passing in a Redis server URI. Your first use case will likely be a simple non-blocking get or set operation within a ReactPHP application — e.g., fetching a cached value without halting the event loop. Check examples/ in the repo for minimal working demos.
Client instance shared across your app for low-overhead, stateful connections. Reuse the connection rather than creating new ones per request.$client->subscribe() and attach callbacks to incoming messages — ideal for real-time features like chat or notifications in long-running processes.$client->pipeline() for bulk operations (e.g., populating caches), reducing network round-trips while preserving non-blocking behavior.Pool or manual): For higher throughput, manually manage multiple clients in a pool or combine with clue/reactphp-mysql-style patterns to avoid bottlenecks.React\Promise (e.g., all(), resolve()) to coordinate Redis I/O with other async operations (HTTP requests, timers, etc.).run() on the loop after issuing commands is critical — forgetting this causes silent failures.PING or using on('close', ...) to re-initialize state.'error' event and returned as rejected promises — always attach both .then(null, $handler) and on('error', ...) for full coverage.json_encode/json_decode manually (or with helpers like clue/reactphp-redis-json) to avoid accidentally storing JSON strings without understanding size/cost.ClientInterface, or use React\Promise\Promise mocks — better yet, test pub/sub/pipeline behavior with a local Redis instance in CI and integration suites.How can I help you explore Laravel packages today?