您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php memcached数据缓存入门例子

2025/5/15 5:48:17发布21次查看
cache = new memcache(); // you can replace localhost by memcached server ip addr and port no. $this->cache->connect('localhost', 10987); } // bbs.it-home.org 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'); ?>
复制代码
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product