yiisoft/yii2-redis
Redis cache, session, mutex, and ActiveRecord support for Yii 2. Store and query structured data in Redis using a familiar ActiveRecord API, with cache and session handlers included.
Cache, Session, Mutex, ActiveRecord) instead of bespoke glue.Mutex) for cron/job deduplication and single-writer guarantees.ActiveRecord implementation lets us model structured data without adding tables or a second database engine — useful for ephemeral or access-pattern-heavy entities (counters, presence, recent-activity, queues of small records) where relational modeling would be overkill.useSSL, scheme => 'tls', contextOptions with client certs) let us commit to encrypted Redis-in-transit for compliance-sensitive environments without custom code, and shape our managed-Redis vendor selection (TLS + password auth support is a checklist item).Adopt when:
Look elsewhere when:
Redis facade, predis/phpredis, cache and session drivers, Cache::lock), so there is nothing to adopt here — the equivalent decision was already made for us by the framework.ActiveRecord cannot support where(), limit(), offset(), orderBy(), or indexBy(), and via relations are unavailable. If the roadmap hints at filtering or pagination over that data, it's the wrong store — choose a relational or document database instead of rediscovering the limitation mid-build.For executives: This is a small, no-cost, official add-on that lets our Yii 2 application use Redis for the three things we most need as we scale — shared caching, centralized sessions, and safe background-job locking. It removes a class of "write it ourselves" work and the associated long-term maintenance, and it ships with documented TLS support that helps us meet security requirements. The primary risk isn't the package; it's the underlying framework's maturity, which is already on our radar. Recommendation: adopt it as the standard Redis integration for Yii 2 services, keep it on the dependency-watch list, and do not use it as a reason to deepen investment in Yii 2 for new products.
For engineering: Use the official extension rather than hand-rolling adapters. It gives us framework-native Cache, Session, Mutex, and ActiveRecord components, plus a raw Connection for Redis-native commands when the abstractions don't fit. Configuration is standard component wiring with TLS via scheme/useSSL and optional client certs. Two constraints to design around from day one: the Redis ActiveRecord has no where/limit/offset/orderBy/indexBy support, and the Predis cluster path cannot back the cache/session/ActiveRecord/mutex components — so pick standalone or Sentinel unless we're deliberately going around those interfaces. Requirements are PHP 7.4+ (8 recommended) and Redis 2.6.12+; verify both in CI before we commit. For any Laravel service, use the framework's built-in Redis support instead — this package does not apply.
How can I help you explore Laravel packages today?