Download the PHP package factorenergia/yii2-tag-dependency-helper without Composer

On this page you can find all versions of the php package factorenergia/yii2-tag-dependency-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-tag-dependency-helper

yii2-tag-dependency-helper

Latest Stable Version Total Downloads Latest Unstable Version License

Helper for unifying cache tag names with invalidation support for Yii2 ActiveRecord models.

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json file.

Core concept

This extension introduces 2 standard cache tags types for ActiveRecord:

Usage

In your active record model add behavior and trait:

This behavior automatically invalidates tags by model name and pair model-id.

Finding model

There's a special method in TagDependencyTrait for finding models by ID with using tag cache:

Example call: $post = Post::loadModel('', false, false, 0, new \Exception("test2"));

For Post model instance($post) cache will be automatically invalidated by object and common tags on update,insert,delete.

Direct invalidation can be done by calling $post->invalidateTags().

Adding cache tags in other scenarios

If your cache entry should be flushed every time any row of model is edited - use getCommonTag helper function:

If your cache entry should be flushed only when exact row of model is edited - use getObjectTag helper function:

If your cache entry should be flushed only when row of model with specified fields is edited - use getCompositeTag helper function and override function cacheCompositeTagFields in model:

Lazy cache

Lazy cache is a technique inspired by iiifx-production/yii2-lazy-cache composer package.

After configuring(see below) you can use it like this:

In this example Pages find query will be performed only if cache entry with key AllActivePages will not be found. After successful retrieving of models array the result will be automatically stored in cache with AllActivePages as cache key for 3600 seconds and with $dependency as Cache dependency.

Configuring - Performance-way

For performance reasons(yii2 behaviors are slower then traits) - create your own \yii\caching\Cache class and add LazyCacheTrait to it, for example:

And modify your application configuration to use your cache component:

Now you can use lazy cache:

Configuring - Behavior-way

Just modify your configuration like this:

Migrating from 0.0.x to 1.x

  1. We have changed namespace from devgroup to DevGroup
  2. We've splitted behavior into 3 components:

Brought to you by DevGroup.ru. Check out our another open-source projects!


All versions of yii2-tag-dependency-helper with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
yiisoft/yii2 Version ~2.0.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package factorenergia/yii2-tag-dependency-helper contains the following files

Loading the files please wait ....