2013-05-28 29 views
0

的財產,我使用Yii PHP框架和memcache緩存,當我打開沒有緩存的頁面,第一次我看到這個錯誤:Yii的高速緩存錯誤:試圖讓非對象

現場錯誤錯誤註銷(Linux版):

Fatal error: Call to a member function getColumnNames() on a non-object in /home/cineshell/cineklik/framework/db/ar/CActiveFinder.php on line 385 

,錯誤日誌本地(窗口):

Trying to get property of non-object 
C:\xampp\htdocs\appfolder\framework\yiilite.php(7125) 
... 
7123  public function getTableSchema() 
7124  { 
7125   return $this->getMetaData()->tableSchema; 
7126  } 

配置/主:

'cache'=> array(
     'class'=> 'CMemCache', 
      'servers'=>array(
      array('host'=>'localhost', 'port'=>11211, 'weight'=>100), 
     ), 
    ), 

緩存例如:

$data = Yii::app()->cache->get('casheID' ); 
if($data===false) 
{ 
    $data = dataprovider, query... etc 
} 
echo $data; 

所以,這裏有什麼錯誤,並且可能是一些在服務器設置?

有人告訴我使用if isset但我不明白!

+0

你在緩存什麼? –

+0

@Aktiiv dataprovider,查詢.. – Abudayah

回答

1

對於CActiveDataProvider,請遵循本指南。 http://www.yiiframework.com/wiki/233/using-cache-in-cactivedataprovider/

另外,您可以根據需要使用片段緩存gridview或部分視圖。我也苦苦掙扎,發現查詢緩存是唯一的工作解決方案。

+0

謝謝,但我可以使用秒緩存依賴項,因爲我沒有update_time? – Abudayah

+0

是的。 $ post = Post :: model() - > cache(1000,$ dependency) - > findAll(); 這裏1000是高速緩存無效的秒數。 看看優秀的文檔: http://www.yiiframework.com/doc/guide/1.1/en/caching.data#using-query-caching-with-activerecord –