和網上說的指示同樣,簡單php
主要核心問題就是擴展有沒有放對。windows
phpinfo(); 頁面中的 「Thread Safety」項目若是是disabled 那麼就是nts,不然就是ts。 數組
TS地址:http://windows.php.net/downloads/pecl/releases/memcache/3.0.8/php_memcache-3.0.8-5.3-ts-vc9-x86.zip測試
NTS地址:http://windows.php.net/downloads/pecl/releases/memcache/3.0.8/php_memcache-3.0.8-5.3-nts-vc9-x86.zip.net
這是32位的擴展包ip
測試代碼:get
<?php
//鏈接Memcache
$mem = new Memcache;
$mem->connect("localhost", 11211);
//保存數據
$mem->set('key1', 'This is first value', 0, 60);
$val = $mem->get('key1');
echo "Get key1 value: " . $val ."<br>";
//替換數據
$mem->replace('key1', 'This is replace value', 0, 60);
$val = $mem->get('key1');
echo "Get key1 value: " . $val . "<br>";
//保存數組數據
$arr = array('aaa', 'bbb', 'ccc', 'ddd');
$mem->set('key2', $arr, 0, 60);
$val2 = $mem->get('key2');
echo "Get key2 value: ";
print_r($val2);
echo "<br>";
//刪除數據
$mem->delete('key1');
$val = $mem->get('key1');
echo "Get key1 value: " . $val . "<br>";
//清除全部數據
$mem->flush();
$val2 = $mem->get('key2');
echo "Get key2 value: ";
print_r($val2);
echo "<br>";
//關閉鏈接
$mem->close();
?> 擴展
運行結果:數據