array('127.0.0.1:11211'),'debug'=> false,'compress_threshold' => 10240, //10k'persistant'=> true)); //添加key,并设置过期时间5秒 $re = $mc->。php对memcached简单的操作。" />

php对memcached简单的操作

//调用文件

include "../memcached.php";

//连接
$mc = new memcached(array( 'servers'=> array('127.0.0.1:11211'), 'debug'=> false, 'compress_threshold' => 10240, //10k 'persistant'=> true) );

//添加key,并设置过期时间5秒
$re = $mc->add('teacher_2', [ 'id'=> '008', 'namer' => '纪老师', 'intro' => '武功高,技术强。哈哈。', ], 5);

//获取对应key值
$re = $mc->get('key');

//更改
$mc->replace(key,value,expire)

【php对memcached简单的操作】//删除对应key
$re= $mc->delete('key');

    推荐阅读