PHPackages                             klsoft/yii2-cache-redis - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. klsoft/yii2-cache-redis

ActiveLibrary[Caching](/categories/caching)

klsoft/yii2-cache-redis
=======================

The package provides the Yii 2 cache using the Redis PHP extension

1.0.0(4mo ago)00MITPHPPHP &gt;=7.4

Since Feb 9Pushed 4mo agoCompare

[ Source](https://github.com/klsoft-web/yii2-cache-redis)[ Packagist](https://packagist.org/packages/klsoft/yii2-cache-redis)[ Docs](https://github.com/klsoft-web/yii2-cache-redis)[ RSS](/packages/klsoft-yii2-cache-redis/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

YII2-CACHE-REDIS
================

[](#yii2-cache-redis)

The package provides the [Yii 2](https://www.yiiframework.com) cache using the [Redis](https://github.com/phpredis/phpredis) PHP extension.

Requirement
-----------

[](#requirement)

- PHP 7.4 or higher.
- [Redis](https://github.com/phpredis/phpredis) PHP extension 6.0.0 or higher.

Installation
------------

[](#installation)

```
composer require klsoft/yii2-cache-redis
```

How to use
----------

[](#how-to-use)

### 1. Configure the Cache.

[](#1-configure-the-cache)

Example:

```
use Yii;
use yii\web\CacheSession;
use Klsoft\Yii2CacheRedis\RedisCache;

return [
    // ...
    'components' => [
        // ...
        'session' => [
            'class' => CacheSession::class,
            'cache' => new RedisCache(
                new Redis([
                    'host' => $params['redisHost'],
                    'port' => $params['redisPort'],
                    'database' => $params['redisDatabaseSession']
                ]))
        ],
        'cache' => new RedisCache(
            new Redis([
                'host' => $params['redisHost'],
                'port' => $params['redisPort'],
                'database' =>  $params['redisDatabaseCache']
            ]))
    ],
];
```

### 2. Cache the data.

[](#2-cache-the-data)

Example:

```
namespace MyNamespace;

use Yii;

final class ProductRepository implements ProductRepositoryInterface
{
    private int $cacheDuration;
    private const TOP_PRODUCTS = 'top_poroducts';

    public function __construct(int $cacheDuration)
    {
        $this->cacheDuration = $cacheDuration;
    }

    public function getTopProducts(int $numberOfTopProducts): array
    {
        return Yii::$app->cache->getOrSet(
            ProductRepository::TOP_PRODUCTS,
            function () use ($numberOfTopProducts) {
                return $this->getTopProductsFromDb($numberOfTopProducts);
            },
            $this->cacheDuration);
    }
}
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance74

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

146d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f4e8ac50e4ad22be84b07f4c06d28cf280d22f689c460cd385c556727e638827?d=identicon)[klsoft-web](/maintainers/klsoft-web)

---

Top Contributors

[![klsoft-web](https://avatars.githubusercontent.com/u/7967163?v=4)](https://github.com/klsoft-web "klsoft-web (1 commits)")

---

Tags

cacheredisyii2rediscacheyii2

### Embed Badge

![Health badge](/badges/klsoft-yii2-cache-redis/health.svg)

```
[![Health](https://phpackages.com/badges/klsoft-yii2-cache-redis/health.svg)](https://phpackages.com/packages/klsoft-yii2-cache-redis)
```

###  Alternatives

[devgroup/yii2-tag-dependency-helper

Helper for unifying cache tag names with invalidation support in yii2

34530.0k7](/packages/devgroup-yii2-tag-dependency-helper)[bazilio/yii2-async

Provides translucent api for moving large tasks out of request context

6249.9k2](/packages/bazilio-yii2-async)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
