Yii Framework Forum: Curlmanager Addcacherules - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Curlmanager Addcacherules Rate Topic: -----

#1 User is offline   KJL Jon 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 18-September 12

Posted 21 November 2012 - 04:15 PM

I am creating an application where there are UserGroups and Users.

The problem is that every UserGroup has a different alias that they like in the Url (but the application is all the same).

One might call Enemies while another Baddies.

I am currently doing this:

and I don't set any rules in the $config.

I would like to take advantage of the Url Caching, but using addRules only addeds it to the $_rules[] and doesn't cache it.

At first, I was thinking to change the private to protected and extending the class and overriding processRules(). But I wanted to find a more "permanent" solution for people to use in the future (without adding another request to make private variables protected).

doing this would require additional cache parameters.

I would like to see something like:
private $_cacheKey=self::CACHE_KEY;

Then here is the function I would for addCacheRules:
public function addCacheRules($rules,$cache='',$append=true)
	if ($append)
		$this->rules = array_merge($rules,$this->rules);
		$this->rules = array_merge($this->rules,$rules);

and then processRules would look as follow (only changed self::CACHE_KEY -> $this->_cacheKey ):
protected function processRules()
	if(empty($this->rules) || $this->getUrlFormat()===self::GET_FORMAT)
	if($this->cacheID!==false && ($cache=Yii::app()->getComponent($this->cacheID))!==null)
		if(($data=$cache->get($this->_cacheKey))!==false && isset($data[1]) && $data[1]===$hash)
	foreach($this->rules as $pattern=>$route)

maybe there is a better way that I am missing?

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users