Home >Backend Development >PHP Tutorial >php中操作memcached缓存进行增删改查数据的实现代码_PHP

php中操作memcached缓存进行增删改查数据的实现代码_PHP

WBOY
WBOYOriginal
2016-06-01 11:49:38873browse

核心代码:

<&#63;php
	
	//创建一个memcache对象实例
	$memcache = new Memcache;
	if(!$memcache->connect("127.0.0.1",11211)){
		die('连接失败');
	}
	if($memcache->set('key1',"xian",MEMCACHE_COMPRESSED,60)){
		echo 'sucess!';
	}//存值,其中xian字符串,也可以为数组,对象,但不能为资源

	$val = $memcache->get('key1');//查询获取值
	echo $val;
	$memcache->replace('key1','beijing',MEMCACHE_COMPRESSED,60);//修改
	   $memcache->delete('key1');//删除
&#63;>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn