开发者

Yii Cache Method Recording

开发者 https://www.devze.com 2023-04-12 23:19 出处:网络
I\'ve just started workin开发者_高级运维g in Yii and I\'m trying to add some functionality to the CClientScript, before beginning overwriting I\'m trying to understand everything it\'s doing so I don\

I've just started workin开发者_高级运维g in Yii and I'm trying to add some functionality to the CClientScript, before beginning overwriting I'm trying to understand everything it's doing so I don't trip myself up later by not including something or including it wrong.

I've spotted a method call when registering scripts/files:

$this->recordCachingAction('clientScript','registerScriptFile',$params);

I've followed this chain down through a few classes to COutputCache in one case and seen the replayActions function. What is this used for? Is there any thing that requires this or is it as my suspicions and it's just a useful debugging feature to track caching?

Tl;Dr:

Why are caching actions recorded for later replaying?


This method saves the output of cached methods. In your example the resulting output of CClientScript->registerScriptFile() will be cached (if caching is enabled, obviously) and saved for later calls. Later, if cache is still valid and CClientScript->registerScriptFile() is called again (with same parameters) the output won't be generated again, but taken from the cache.

Basically this is modular cache based on methods (most of methods affecting output are cached). Of course you can use it in your models, controllers and etc.


Johnatan's answer is a correct and a good description of what it does. But I got a more detailed insight (which is more what I was looking for) into how it does it here:

YiiFramework.com Forum Topic

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号