開始->運行->輸入cmd,命令行打開memcached.exe,所在文件夾,輸入:memcached.exe -d install 安裝
輸入memcached.exe -d start 啟動
打開yii配置文件:config/main.php , 在components 下添加:
[html]
'memcache'=>array(
'class'=>'CMemCache',
'servers'=>array(
array(
'host'=>'127.0.0.1',
'port'=>11211,
'weight'=>60,
),
array(
'host'=>'127.0.0.1',
'port'=>11211,
'weight'=>40,
),
),
),
'memcache'=>array(
'class'=>'CMemCache',
'servers'=>array(
array(
'host'=>'127.0.0.1',
'port'=>11211,
'weight'=>60,
),
array(
'host'=>'127.0.0.1',
'port'=>11211,
'weight'=>40,
),
),
),
使用:
[html]
Yii::app()->memcache->get(id);
Yii::app()->memcache->set(id,value,time);
Yii::app()->memcache->get(id);
Yii::app()->memcache->set(id,value,time);