Interval Constants Inside Ccache

Over the development of yii meanings of sending 0 or -1 as duration to cache components have varied. Though its not difficult to remember these mappings but some sort of constants would appeal more, specially in terms of code readability to a new developer, that is:




$this->beginCache($id, array('duration' => CCache::DISABLE));



is better than:




$this->beginCache($id, array('duration' => 0));



Few of the constants that i could think are:

  • DISABLE (same as 0)

  • PURGE_DISABLE (same as -1)

  • FOREVER (same as specifying a month or 2, this could actually depending on cache component like for APC it could be 7 days, for file it could be a month)

Credit: cpamplona on #yii

Original Post: http://www.yiiframework.com/forum/index.php/topic/38364-cached-forever-made-easy/

Agree. I think it can be done in 1.1 in case of cache but it’s definitely the style we’ll follow for Yii2.