PHPackages                             klsoft/yii3-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/yii3-cache-redis

ActiveLibrary[Caching](/categories/caching)

klsoft/yii3-cache-redis
=======================

The package provides the PSR-16 cache using the Redis PHP extension

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

Since Feb 17Pushed 4mo agoCompare

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

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

YII3-CACHE-REDIS
================

[](#yii3-cache-redis)

The package provides the [PSR-16](https://www.php-fig.org/psr/psr-16/) cache using the [Redis](https://github.com/phpredis/phpredis) PHP extension.

See also:

- [YII3-CACHE-SESSION-HANDLER](https://github.com/klsoft-web/yii3-cache-session-handler) - The package implements the SessionHandlerInterface using the [PSR-16](https://www.php-fig.org/psr/psr-16/) cache for storage

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

[](#requirement)

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

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

[](#installation)

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

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

[](#how-to-use)

### 1. Configure the CacheInterface.

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

Example:

```
use Yiisoft\Cache\CacheInterface;
use Yiisoft\Cache\Cache;
use Klsoft\Yii3CacheRedis\RedisCache;

return [
    // ...
    CacheInterface::class => [
        'class' => Cache::class,
        '__construct()' => [
            'handler' => new RedisCache(
                new Redis([
                    'host' => $params['redisHost'],
                    'port' => $params['redisPort'],
                    'database' => $params['redisDatabase']
                ])
            )
        ],
    ]
];
```

### 2. Cache the data.

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

Example:

```
namespace MyNamespace;

use Yiisoft\Cache\CacheInterface;

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

    public function __construct(
        private CacheInterface $cache,
        private int            $cacheDuration)
    {
    }

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

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance75

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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

137d 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

cacheredisyii3rediscachepsr-16yii3

### Embed Badge

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

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

###  Alternatives

[laminas/laminas-cache

Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output

1077.3M154](/packages/laminas-laminas-cache)[sabre/cache

Simple cache abstraction layer implementing PSR-16

551.3M5](/packages/sabre-cache)[cache/redis-adapter

A PSR-6 cache implementation using Redis (PhpRedis). This implementation supports tags

584.1M27](/packages/cache-redis-adapter)[cache/simple-cache-bridge

A PSR-6 bridge to PSR-16. This will make any PSR-6 cache compatible with SimpleCache.

433.3M28](/packages/cache-simple-cache-bridge)

PHPackages © 2026

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