memcache实例

<?php

class demo { private $str_attr; private $int_attr; public function __get($name) { return $this->$name; } public function __set($name, $value) { $this->$name = $value; } } $memcache = new Memcache; $memcache->connect(‘localhost‘, 11211); $version = $memcache->getversion(); echo "Server‘s version: " . $version; $tmp_object = new demo(); $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)<br />\n"; $get_result = $memcache->get(‘key‘); echo "Data from the cache:<br />\n"; var_dump($get_result); echo $get_result->str_attr; echo $get_result->int_attr; ?>

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。