您好,欢迎访问一九零五行业门户网

php的数据对象、构造的存储

php的数据对象、结构的存储
1.使用序列化和反序列化函数,?然后将序列化结果$result存储到文件或者数据库中进行持久存储
$result = serialize($data);
?
$data = unserialize($result)?
?
2.使用分布式内存对象缓存系统 memcached
2.1安装memcached客户端 将数据存储在该客户端的内存中
win32版memcached?http://code.jellycan.com/memcached/
可安装为服务
?
memcached -d install
memcached -d start
?
2.2安装php扩展
下载?http://shikii.net/blog/downloads/php_memcache-cvs-20090703-5.3-vc6-x86.zip
编辑php.ini extension=php_memcache.dll
示例代码:
?
?
connect('localhost', 11211) or die (could not connect);$version = $memcache->getversion();echo server's 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 (failed 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);?>
?参考网址:http://shikii.net/blog/installing-memcached-for-php-5-3-on-windows-7/
?
其它类似信息

推荐信息