Hello to everybody!
I have developed new component CachedModelBehavior. 3275
Here is brief description.
/**
* CachedModelBehavior handles model caching and its synchronization with main data
* storage.
*
* This component creates middle storage for used models in cache. Thus, it helps
* significantly alleviate DB server load. You may define time interval between data
* synchronizations from cache to main data storage.
*
* Component is recommended for frequently requested/updated small pieces of data.
* Stored data should be not so significant, because it may be (rarely, but...)
* removed from cache storage: it is fast but trustless storage. For example,
* component may be used to store user visits, user likes etc in cache. It would be
* great, if you could use more reliable storage for data, such as Redis.
*
* <b>Note:</b> it is not recommended for important user data (like passwords,
* payment transactions etc.), for large size or rarely requested/updated data
* (blog posts, logs etc.).
*
* All api methods have the same names and arguments, as CActiveRecord class. So,
* if you set {@link CachedModelBehavior::isEnabled} to false or if there is no
* cached attributes, all methods will be simply downgraded to CActiveRecord
* methods, without using cache storage. No code changes needed anymore.
*
* class MyModel extends CActiveRecord
* {
*
* ...
*
* public function behaviors()
* {
* return array(
* 'cachedModel' => array(
* 'class' => 'CachedModelBehavior',
* 'fields' => '',
* 'excludedFields' => 'action,userid',
* 'syncInterval' => 15,
* 'delayedInsert' => true,
* ),
* );
* }
*
* ...
* }
*
* DO NOT use component on your production servers! It is not well tested yet.
*/
I have no posts at this forum, so I can’t upload component to ‘Extensions’ part of site. But please, please, feel you free to ask, make suggestions, report about possible bugs. I have tested it, but, may be, missed something.
Also your opinion about component will be greatly appreciated. Please, show me my mistakes. I want to improve my programming skills, again and again.
Thank you!