This extension can be used to cache function or method output in Memcache or other cache you specified.Usually,some functions's call will connect to the database,compute the result base many data records,these operation will waste much time,and lot of them can be cached(Maybe you even do this though memcache api or Yii::app()->cache->set manually).For example,select user's profiles from the database,the result should be cache in memory and keep 2 minutes than expires(or until the user modified his profiles).
You should specify a cache components at least.
CacheDecor is a configurable components.Just one php file. You can put it in your app components directory and add it to components config:
'components'=>array( 'cacheDecor'=>array( 'class'=>'application.components.CacheDecor', 'cacheID'=>'cache',//You must specify one cache component at leat. ) )
When you want to call a function with automatically cache,you can use
//Call a function Yii::app()->cacheDecor->run('your_function_name',$argumentsArray); //Or a method Yii::app()->cacheDecor->run(array($myObject,'theMethodNameHere'),$argsArray);
Another usage,it can auto decorate a method call. But this way may be obtrusive.You must use a method prefix.So I do not introduct it for more.
For more usage and config documentation,please read the comment in the php file.
Here is a post about memoization in php:http://jex.im/programming/memoization-in-php.html
Also,in the archive,I upload the TestCase besides the CacheDecor class. TestCase shows more usage of class CacheDecor.