illuminate/redis
Illuminate Redis provides Laravel’s Redis integration, delivering cache, queue, session, and pub/sub support via a simple API. Works with PhpRedis or Predis, supports clusters and connections, and plugs into the framework’s Cache and Queue systems.
Begin by installing via Composer (composer require illuminate/redis) and setting up a connection in your config/database.php under the redis key. The package expects standard Redis connection details (host, port, password, prefix, persistent ID). In Laravel apps, this is handled automatically, but standalone usage requires bootstrapping a RedisManager with your config. Start with basic operations: resolve the manager via DI or instantiate directly, then use redis()->set('key', 'value') and redis()->get('key'). The entry point is the Illuminate\Redis\RedisManager class—check its connection() and driver() methods.
Redis facade or Illuminate\Support\Facades\Redis for simple, static-style access in controllers/middleware. For testability and SOLID compliance, inject Illuminate\Redis\RedisManager or Illuminate\Contracts\Redis\Factory.config/database.redis.client. Prefer PhpRedis for performance, but Predis offers better compatibility and flexibility (e.g., clustering).cluster or sentinel sections in your Redis config. Use redis()->connection('cluster') or redis()->connection('sentinel') to access them.redis()->script() or redis()->eval() for atomic operations. Scripts can be loaded once via registerScript() for reuse.subscribe()/publish() or xread()/xadd() via the manager. Patterns often wrap these in service classes with retry logic and error handling.config()—you must manually provide config arrays. The RedisManager won’t auto-configure default connections without explicit setup.'persistent' => true). Ensure you manage connection lifetime and avoid stale handles in CLI/forking contexts.'prefix' option applies universally. If running multiple apps against the same Redis, mismatched prefixes can cause collisions or silent overwrites.'serializer' => 'none' in config if handling raw strings for performance.predis/predis with Predis\Client::connect() and mock RedisManager in unit tests—avoid hitting real Redis during tests. Laravel’s Redis::shouldReceive() won’t work standalone.illuminate/* versions. If you’re on Laravel 13, ensure all illuminate packages (e.g., illuminate/contracts) are ^13.0 to avoid Class not found errors.How can I help you explore Laravel packages today?