memcache锁,解决查询过多email查询为空的问题

/* 设置memcache锁,解决查询过多email查询为空的问题 Begin */
$mmc = new Memcache;
$mmc->connect('127.0.0.1', 11211) or die ("Could not connect");
if(!empty($mmc)){
$sending=$mmc->get('sending');
$sending=intval($sending);
}else{
//如果不能使用memcache,则以不影响发送为主
$sending=0;
}
if($sending==1) die("发送频率太大,请稍后再试.");
/* 发送开始 */
$mmc->add('sending',1);
$result=$db->fetch_first("SELECT email from table ");
sendmail("$result[email]",title,content);
$mmc->replace('sending',0);
/* 设置memcache锁,解决查询过多email查询为空的问题 End */

posted on 2014-02-21 17:20  BuildyMan  阅读(275)  评论(0编辑  收藏  举报

导航