wyrihaximus/react-cache-redis
Redis-backed cache adapter for ReactPHP implementing the react/cache interface. Built on clue/reactphp-redis, supports key prefixing, and integrates with async React event loops for fast, non-blocking caching in your applications.
This package is not for Laravel—it’s for ReactPHP applications requiring non-blocking Redis caching. Laravel’s synchronous cache system (Illuminate\Contracts\Cache) is fundamentally incompatible with react/cache. If you’re using Laravel, this package serves no purpose; use Laravel’s built-in redis cache driver instead.
To get started only if building an event-driven app with ReactPHP:
composer require wyrihaximus/react-cache-redis clue/redis-react$client = (new \Clue\React\Redis\Factory())->createLazyClient();
$cache = new \WyriHaximus\React\Cache\Redis($client, 'myapp:cache:v1:');
react/cache implementation (e.g., Promise $cache->get('key'), Promise $cache->set('key', $value, $ttl)).await (with React\Promise\resolve() or async functions) or chain with then().'service:env:version:') to prevent key collisions across microservices or environments.createLazyClient()—it defers connection until the first operation, avoiding startup blocking and handling reconnection automatically.react/http) by injecting the cache instance into request handlers:
$server->on('request', function ($req, $res) use ($cache) {
$cache->get('user:' . $id)->then(function ($data) use ($res) {
// non-blocking cache hit
$res->writeHead(200);
$res->end($data);
});
});
react/cache's int|float|null $ttl signature.SETEX uses integer seconds; float TTLs are cast silently. Validate TTLs for sub-second precision needs (e.g., max(1, (int)$ttl)).: to avoid truncated keys (e.g., 'prefix' + 'key' → 'prefixkey' is broken; 'prefix:' is safe).2025-04-27 is likely a packaging artifact, but verify composer.json's require.php matches your runtime (currently PHP 8.3+).$cache->withSerializer() if caching complex objects or needing compression (e.g., with igbinary or zlib).How can I help you explore Laravel packages today?