Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Redis Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

  • Laravel Integration: Use 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.
  • Predis vs PhpRedis: The package auto-detects the client (Predis or PhpRedis extension); configure via config/database.redis.client. Prefer PhpRedis for performance, but Predis offers better compatibility and flexibility (e.g., clustering).
  • Cluster & Sentinel Support: Define cluster or sentinel sections in your Redis config. Use redis()->connection('cluster') or redis()->connection('sentinel') to access them.
  • Lua Scripting: Leverage redis()->script() or redis()->eval() for atomic operations. Scripts can be loaded once via registerScript() for reuse.
  • Pub/Sub & Streams: Use subscribe()/publish() or xread()/xadd() via the manager. Patterns often wrap these in service classes with retry logic and error handling.

Gotchas and Tips

  • Standalone Caveats: No Laravel helpers like config()—you must manually provide config arrays. The RedisManager won’t auto-configure default connections without explicit setup.
  • Connection Pooling: PhpRedis connections persist by default ('persistent' => true). Ensure you manage connection lifetime and avoid stale handles in CLI/forking contexts.
  • Prefixing: The 'prefix' option applies universally. If running multiple apps against the same Redis, mismatched prefixes can cause collisions or silent overwrites.
  • Serialization: The manager automatically serializes non-string data using Laravel’s serializer. Disable with 'serializer' => 'none' in config if handling raw strings for performance.
  • Testing: Use 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.
  • Upgrade Paths: This is a subtree split—always match your 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.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4