CGlobalStateCacheDependency COutputCache invalidation performance?

Hi,

I’m using COutputCache to cache the new index, news pages and feed pages on my new site and had a requirement to invalidate these at will, I worked out that I could use CGlobalStateCacheDependency with a unique key and then simply change that particular state when I wished to invalidate the output cache. My only concern however is performance, I understand that the GlobalState is stored in the runtime/state.bin file, does this mean that every time someone hits one of my cached pages Yii is reading that file or does it cache the state in Cache() ?

Here’s some code snippets:

From FeedsController:




public function filters()

{

	$newsDependency = New CGlobalStateCacheDependency('cacheNews');

	return array(

		array(                                          // Cache RSS feeds

			'COutputCache',

			'duration'=>900,    // 15 minutes

			'dependency'=>$newsDependency,

		),

	);

}



From my model whenever I need to invalidate anything which has the ‘cacheNews’ dependency:




Yii::app()->setGlobalState('cacheNews', microtime(true));



This works really well but again I’m concerned about performance and scalability.

From the Yii sourcecode (below) it’s clear to see that globalState is stored in the Yii::app() object or loaded if its not and it looks like loadGlobalState() uses CStatePersister which does indeed use the cache()… Please correct me if I’m wrong.




        /**

         * Returns a global value.

         *

         * A global value is one that is persistent across users sessions and requests.

         * @param string $key the name of the value to be returned

         * @param mixed $defaultValue the default value. If the named global value is not found, this will be returned instead.

         * @return mixed the named global value

         * @see setGlobalState

         */

        public function getGlobalState($key,$defaultValue=null)

        {

                if($this->_globalState===null)

                        $this->loadGlobalState();

                if(isset($this->_globalState[$key]))

                        return $this->_globalState[$key];

                else

                        return $defaultValue;

        }