核心代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<?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' ); //删除
?>
|