PHPackages                             t-kanstantsin/yii2-cache-model - 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. t-kanstantsin/yii2-cache-model

ActiveYii2-extension[Caching](/categories/caching)

t-kanstantsin/yii2-cache-model
==============================

Caching static models component for Yii 2 framework.

01451PHP

Since Mar 17Pushed 10y agoCompare

[ Source](https://github.com/t-kanstantsin/yii2-cache-model)[ Packagist](https://packagist.org/packages/t-kanstantsin/yii2-cache-model)[ RSS](/packages/t-kanstantsin-yii2-cache-model/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Caching static models component for Yii 2
=========================================

[](#caching-static-models-component-for-yii-2)

Component allows easy cache and get static models data like statuses, cities or categories. There are methods to manually clear cache in purpose to update those data.

Install
-------

[](#install)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
$ php composer.phar require --prefer-dist t-kanstantsin/yii2-cache-model "*"
```

or add

```
"t-kanstantsin/yii2-cache-model": "*"
```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

To configure component place this code in config's component definition:

```
    'cacheModel' => [
        'class' => tkanstantsin\cache\CacheModel::class,
        'cache' => 'cache', // cache component
        'duration' => 86400, // caching time (it can't be greater than in 'cache' component)
    ],
```

### List of all cached models by class name

[](#list-of-all-cached-models-by-class-name)

```
\Yii::$app->cacheModel->get(foo\Foo::class);
```

### Particular model

[](#particular-model)

```
\Yii::$app->cacheModel->get(foo\Foo::class, $fooId);
```

### Array of models

[](#array-of-models)

```
\Yii::$app->cacheModel->get(foo\Foo::class, [$fooId1, $fooId2]);
```

### Manually clear cache

[](#manually-clear-cache)

```
\Yii::$app->cacheModel->flush(foo\Foo::class);

```

Credits
-------

[](#credits)

- [Konstantin Timoshenko](https://github.com/t-kanstantsin)

License
-------

[](#license)

The BSD License (BSD). Please see [License File](LICENSE.md) for more information.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d4163e3f004a6097faad7270c284f429841e2a3d66db295c386d646181e6fd0a?d=identicon)[tkanstantsin](/maintainers/tkanstantsin)

---

Top Contributors

[![k-timoshenko](https://avatars.githubusercontent.com/u/3259675?v=4)](https://github.com/k-timoshenko "k-timoshenko (10 commits)")

### Embed Badge

![Health badge](/badges/t-kanstantsin-yii2-cache-model/health.svg)

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

###  Alternatives

[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)[phpfastcache/phpssdb

PHP SSDB Driver for phpFastCache

14736.9k1](/packages/phpfastcache-phpssdb)

PHPackages © 2026

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