PHPackages                             herroffizier/yii2-ar-tag-cache - 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. herroffizier/yii2-ar-tag-cache

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

herroffizier/yii2-ar-tag-cache
==============================

Yii 2 component for automatic cache invalidation invoked by ActiveRecord updates.

1.0.0(9y ago)1912BSD-3-ClausePHPPHP &gt;=5.4

Since Apr 9Pushed 9y ago1 watchersCompare

[ Source](https://github.com/herroffizier/yii2-ar-tag-cache)[ Packagist](https://packagist.org/packages/herroffizier/yii2-ar-tag-cache)[ RSS](/packages/herroffizier-yii2-ar-tag-cache/feed)WikiDiscussions develop Synced today

READMEChangelogDependencies (6)Versions (3)Used By (0)

Yii2 AR Tag Cache
=================

[](#yii2-ar-tag-cache)

[![Build Status](https://camo.githubusercontent.com/e362b4862d7ec194246b9dac82d89afcb3ee3eaf0594d348d566476796483270/68747470733a2f2f7472617669732d63692e6f72672f686572726f6666697a6965722f796969322d61722d7461672d63616368652e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/herroffizier/yii2-ar-tag-cache) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/6e19a3f61c5bd8b2808c5fd4d5bfebcaa60efc2e0c1669977d3b0b2b7990d4f5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f686572726f6666697a6965722f796969322d61722d7461672d63616368652f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/herroffizier/yii2-ar-tag-cache/?branch=develop) [![Code Coverage](https://camo.githubusercontent.com/668854f47875d8a9761d36a0e5eacecfe774394647c4ac4e0f66a97591eedbd0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f686572726f6666697a6965722f796969322d61722d7461672d63616368652f6261646765732f636f7665726167652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/herroffizier/yii2-ar-tag-cache/?branch=develop)

Yii2 AR Tag Cache automatically invalidates tagged cache when ActiveRecord changes.

In fact it is a simple wrapper over Yii2's `TagDependency`. It creates special tag for ActiveRecord class and invalidates all cache marked by that tag when any of that class instances is being created, updated or deleted.

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

[](#installation)

Install extension with Composer:

```
composer require "herroffizier/yii2-ar-tag-cache:@stable"
```

Attach behavior to AR model:

```
public function behaviors()
{
    return [
        'arCache' => [
            'class' => \herroffizier\yii2artc\Behavior::className(),
        ],
    ];
}
```

Usage
-----

[](#usage)

```
// Get tag dependency:
$dependency = $model->tagDependency;

// Attach dependency to cache:
Yii::$app->cache->set('cache', 'test', 0, $dependency);

// Now if you call save() or delete() for any instance of $model's class, cache will be invalidated.
// Also you may force cache invalidation without modifying models:
$model->invalidateCache();
```

###  Health Score

28

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

3636d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/820232d3f5de11b08332a98ca93b025ab46d7e3563ddaec2ce6d042828718983?d=identicon)[herroffizier](/maintainers/herroffizier)

---

Top Contributors

[![korotin](https://avatars.githubusercontent.com/u/277992?v=4)](https://github.com/korotin "korotin (4 commits)")

---

Tags

cacheyii2yiiactiverecordyii 2cache dependencycache tagtag dependency

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/herroffizier-yii2-ar-tag-cache/health.svg)

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

###  Alternatives

[devgroup/yii2-tag-dependency-helper

Helper for unifying cache tag names with invalidation support in yii2

32500.9k6](/packages/devgroup-yii2-tag-dependency-helper)[undefinedor/yii2-cached-active-record

The cached activeRecord for the Yii2 framework

102.6k](/packages/undefinedor-yii2-cached-active-record)

PHPackages © 2026

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