php加锁修改密码,PHP加锁解锁操作

该代码实现了一个名为classLockCAO的类,用于管理不同类型的锁,包括用户ID锁、会话ID锁和全局锁。它包含了添加、获取和删除锁的操作,使用了特定的配置和键生成方法。主要功能涉及缓存操作,如添加、获取和删除缓存项。
摘要由CSDN通过智能技术生成

class LockCAO extends CAO

{

private $TP_LOCK_ACT_UID = 'lock_act_uid';

private $TP_LOCK_ACT_SID = 'lock_act_sid';

private $TP_LOCK_ACT_GLOBAL = 'lock_act_global';

protected function mao_config($type)

{

$maoconfig = null;

switch($type)

{

case $this->TP_LOCK_ACT_UID:

$maoconfig = array(

'xcache_enable' => false,

'xcache_expire' => 0,

'is_bin'=> false,

'mc_key'=> 'lock_act_uid',

);

break;

case $this->TP_LOCK_ACT_SID:

$maoconfig = array(

'xcache_enable' => false,

'xcache_expire' => 0,

'is_bin'=> false,

'mc_key'=> 'lock_act_sid',

);

break;

case $this->TP_LOCK_ACT_GLOBAL:

$maoconfig = array(

'xcache_enable' => false,

'xcache_expire' => 0,

'is_bin'=> false,

'mc_key'=> 'lock_act_global',

);

break;

}

return $maoconfig;

}

public function make_key($type,$uid=0,$sid=0)

{

$key = '';

switch ($type)

{

case $this->TP_LOCK_ACT_UID:

$key = $uid;

break;

case $this->TP_LOCK_ACT_SID:

$key = $sid;

break;

}

return $key;

}

public function addActUid($uid,$r=1)

{

$key = $this->make_key($this->TP_LOCK_ACT_UID, $uid);

$res = $this->mcadd($this->TP_LOCK_ACT_UID, $key, $r, $uid, 10);

if($res===false) return false;

return true;

}

public function getActUid($uid)

{

$key = $this->make_key($this->TP_LOCK_ACT_UID, $uid);

$res = $this->mcget($this->TP_LOCK_ACT_UID, $key, $uid);

if($res===false) return false;

return $res;

}

public function delActUid($uid)

{

$key = $this->make_key($this->TP_LOCK_ACT_UID, $uid);

$res = $this->mcdel($this->TP_LOCK_ACT_UID, $key);

if($res===false) return false;

return true;

}

public function addActSid($sid)

{

$key = $this->make_key($this->TP_LOCK_ACT_SID, "", $sid);

$res = $this->mcadd($this->TP_LOCK_ACT_SID, $key, time() , $uid, $expire_time = 10);

if($res===false) return false;

return true;

}

public function delActSid($sid)

{

$key = $this->make_key($this->TP_LOCK_ACT_SID, "", $sid);

$res = $this->mcdel($this->TP_LOCK_ACT_SID, $key);

if($res===false) return false;

return true;

}

public function addActGlobal($key,$r=1)

{

//$key = $this->make_key($this->TP_LOCK_ACT_UID, $uid, $sid);

$res = $this->mcadd($this->TP_LOCK_ACT_GLOBAL, $key, $r, $key, 10);

if($res===false) return false;

return true;

}

public function delActGlobal($key)

{

//$key = $this->make_key($this->TP_LOCK_ACT_GLOBAL, $uid, $sid);

$res = $this->mcdel($this->TP_LOCK_ACT_GLOBAL, $key);

if($res===false) return false;

return true;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值