ob_start();
$content = ob_get_contents();
ob_end_clean();
2.
$memcachehost = '192.168.6.191';
$memcacheport = 11211;
$memcachelife = 60;
$memcache = newMemcache;
$memcache->connect($memcachehost,$memcacheport) or die ("Could not connect");
$memcache->set('key','缓存的内容');
$get = $memcache->get($key);
8.
$memcache = new Memcache;
$memcache->connect('localhost',11211) or die ("could not connect");
$version = $memcache->getVersion();
echo "Server version:“.$version."\n”;
$tmp_object = new stdclass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$memcache->set('key',$tmp_object,false,10) or die ("Faild to save data at the server ");
echo "store data in the cache(data will expire in 10 seconds)\n";
$get_result = $memcache->get('key');
echo "Data from the cache:\n";
var_dump($get_result);
$sql = "select * from users";
$key = md5($sql);
if(!$data = $mc->get($key)){
echo "n".str_pad(Read datas from mysql ',60,'_')."n";
$conn = mysql_connect('localhost','test','test');
mysql_select_db('test');
$result = mysql_query($sql);
while ($row = mysql_fetch_object($result)){
$datas[] = $row;
$mc->add($key,$datas);
else{
echo "n".str_pad('Read datas from memcached',
var_dump($datas)
mysql_query("insert into tablename('id','name') values('1','mike') or exit("MYSQL ERROR:“ .mysql_error());
'DATA_CACHE_TYPE'=>'file',
'DATA_CACHE_TIME'=>'600',
S('data',$Data);
S('data',$Data,600);
$Data = S('data');
S('data',Null);