Recommend this page to a friend! |
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 [
'ArSyncBehavior'=>[
'class' => ArSyncBehavior::class,
'slaveModel' => \your\model\namespase\Slave::className(),
'slaveScenario'=>'sync',
'errorSaveCallback'=>function($slave){
Yii::error(VarDumper::export($slave->errors));
throw new InvalidConfigException('fail save ');
},
'errorDeleteCallback'=>function($slave){
Yii::error('fail delete '.$slave->getPrimaryKey());
},
'fieldMap' => [
'id'=>'id',
'title' => 'name',
'foo' => 'foo',
'bar' => 'bar',
'baz' => function($master)
{
return $master->baz * 2;
},
],
]
];
}
Classes of Insolita | > | yii2-arsync | > | Download .zip .tar.gz | > | Support forum | > | Blog | > | Latest changes |
|
Groups | Applications | Files |
Groups |
PHP 5 | Classes using PHP 5 specific features | View top rated classes |
Databases | Database management, accessing and searching | View top rated classes |
Design Patterns | Implementations of well known design patterns | View top rated classes |
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.
Files |
File | Role | Description | ||
---|---|---|---|---|
tests (1 directory) | ||||
ArSyncBehavior.php | Class | Class source | ||
composer.json | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files | / | tests | / | codeception | / | common |
File | Role | Description | ||
---|---|---|---|---|
migrations (1 file) | ||||
unit (1 file, 2 directories) | ||||
PrivateTestTrait.php | Class | Class source |
Files | / | tests | / | codeception | / | common | / | migrations |
File | Role | Description |
---|---|---|
m160511_151843_synctest.php | Class | Class source |
Files | / | tests | / | codeception | / | common | / | unit |
File | Role | Description | ||
---|---|---|---|---|
behaviors (1 file) | ||||
fixtures (4 files) | ||||
TestCase.php | Class | Class source |
Files | / | tests | / | codeception | / | common | / | unit | / | behaviors |
File | Role | Description |
---|---|---|
ArSyncBehaviorTest.php | Class | Class source |
Files | / | tests | / | codeception | / | common | / | unit | / | fixtures |
File | Role | Description |
---|---|---|
DbMaster.php | Class | Class source |
DbSlave.php | Class | Class source |
RedisMaster.php | Class | Class source |
RedisSlave.php | Class | Class source |
Download all files: yii2-arsync.tar.gz yii2-arsync.zip NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
|
Files |
File | Role | Description | ||
---|---|---|---|---|
tests (1 directory) | ||||
ArSyncBehavior.php | Class | Class source | ||
composer.json | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files | / | tests | / | codeception | / | common |
File | Role | Description | ||
---|---|---|---|---|
migrations (1 file) | ||||
unit (1 file, 2 directories) | ||||
PrivateTestTrait.php | Class | Class source |
Files | / | tests | / | codeception | / | common | / | migrations |
File | Role | Description |
---|---|---|
m160511_151843_synctest.php | Class | Class source |
Files | / | tests | / | codeception | / | common | / | unit |
File | Role | Description | ||
---|---|---|---|---|
behaviors (1 file) | ||||
fixtures (4 files) | ||||
TestCase.php | Class | Class source |
Files | / | tests | / | codeception | / | common | / | unit | / | behaviors |
File | Role | Description |
---|---|---|
ArSyncBehaviorTest.php | Class | Class source |
Files | / | tests | / | codeception | / | common | / | unit | / | fixtures |
File | Role | Description |
---|---|---|
DbMaster.php | Class | Class source |
DbSlave.php | Class | Class source |
RedisMaster.php | Class | Class source |
RedisSlave.php | Class | Class source |
Download all files: yii2-arsync.tar.gz yii2-arsync.zip NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
|