首页 > 系统服务 > 详细

memcache实例

时间:2015-01-27 23:17:52      阅读:408      评论:0      收藏:0      [点我收藏+]
<?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; ?>

memcache实例

原文:http://www.cnblogs.com/timelesszhuang/p/4254074.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!