本文较为详细的讲述了php下Memcached的入门知识与实例。分享给大家供大家参考。具体如下:
memcache 在什么情况下被使用,什么情况下不要使用"codetitle">复制代码 代码如下:<?php
class mycache
{
private $cache;
function __construct()
{
$this->cache = new memcache();
// you can replace localhost by memcached server ip addr and port no.
$this->cache->connect('localhost', 10987);
}
function get_data($key)
{
$data = $this->cache->get($key);
if($data != null)
return $data;
else
{
if($this->cache->getresultcode() == memcached::res_notfound)
{
//do the databse query here and fetch data
$this->cache->set($key,$data_returned_from_database);
}
else
{
error_log('no data for key '.$key);
}
}
}
}
$cache = mycache();
$cache->get_data('foo');
?>
希望本文所述对大家的php程序设计有所帮助。
php,Memcached,入门
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 贵族音乐《古典名曲与轻音乐钢琴 打开宝宝睡眠开关》[320K/MP3][155.91MB]
- 贵族音乐《古典名曲与轻音乐钢琴 打开宝宝睡眠开关》[FLAC/分轨][251.78MB]
- 黄韵玲2001-巴结音乐[全员集合][WAV+CUE]
- 郑绪岚2015-流金岁月·精选[首版][WAV+CUE]
- 周冰倩1995《沧桑情歌》JVC日本录制[WAV+CUE]
- 辛禄乐队.2024-热烈的少年【星辰】【FLAC分轨】
- 成龙.1996-龙的心【滚石】【WAV+CUE】
- 童安格.1991-一世情缘【宝丽金】【WAV+CUE】
- 韩红2010-擦肩而过[央金玛][WAV+CUE]
- RiccardoTesi-UnballoLiscio,Vol.II(2024)[24-48]FLAC
- 金池VS刘罡2009《双声情》[WAV+CUE]
- 冯奥迪《卄》[320K/MP3][67.08MB]
- 冯奥迪《卄》[FLAC/分轨][172.46MB]
- Merryland《Merryland》[320K/MP3][69.48MB]
- 苏芮.1991-停在我心里的温柔【福茂】【WAV+CUE】