PHP Classes


Recommend this page to a friend!
  Classes of Insolita   yii2-arsync   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: yii2-arsync
Add new behaviors to active record actions
Author: By
Last change:
Date: 1 year ago
Size: 1,707 bytes


Class file image Download

ActiveRecord Synchronization Behavior

This behavior for automatic or manual sync data between two models, without declaration relation. This behavior must be attached on master model. Main purposes - for sync rarely modified data from more reliable database storage to redis storage for frequently access; Support actual data state in some development cases;


The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist insolita/yii2-arsync "*"

or add

"insolita/yii2-arsync": "*"

to the require section of your composer.json file.


Once the extension is installed, simply use it in your code by : See more in code

public function behaviors(){
    return [
       				'class'      => ArSyncBehavior::class,
       				'slaveModel' => \your\model\namespase\Slave::className(),
                          throw new InvalidConfigException('fail save ');
                        Yii::error('fail delete '.$slave->getPrimaryKey());
       				'fieldMap' => [
       					'title' => 'name',
       					'foo'   => 'foo',
       					'bar'   => 'bar',
       					'baz'   => function($master)
       						return $master->baz * 2;