PHP Class Cml\Lock\Base

Inheritance: implements Cml\Interfaces\Lock
Afficher le fichier Open project: linhecheng/cmlphp

Protected Properties

Свойство Type Description
$expire integer 锁的过期时间针对Memcache/Redis两种锁有效,File锁无效 单位s 设为0时不过期。此时假如开发未手动unlock且这时出现程序挂掉的情况 __destruct未执行。这时锁必须人工介入处理 这个值可根据业务需要进行修改比如60等
$lockCache array 保存锁数据
$useCache string 锁驱动使用redis/memcache时使用的缓存

Méthodes publiques

Méthode Description
__construct ( $useCache )
__destruct ( ) 定义析构函数 自动释放获得的锁
setExpire ( integer $expire = 100 ) 设置锁的过期时间
unlock ( string $key ) : void 解锁

Méthodes protégées

Méthode Description
getKey ( string $key ) : string 组装key

Method Details

__construct() public méthode

public __construct ( $useCache )

__destruct() public méthode

定义析构函数 自动释放获得的锁
public __destruct ( )

getKey() protected méthode

组装key
protected getKey ( string $key ) : string
$key string 要上的锁的key
Résultat string

setExpire() public méthode

设置锁的过期时间
public setExpire ( integer $expire = 100 )
$expire integer

unlock() public méthode

解锁
public unlock ( string $key ) : void
$key string
Résultat void

Property Details

$expire protected_oe property

锁的过期时间针对Memcache/Redis两种锁有效,File锁无效 单位s 设为0时不过期。此时假如开发未手动unlock且这时出现程序挂掉的情况 __destruct未执行。这时锁必须人工介入处理 这个值可根据业务需要进行修改比如60等
protected int $expire
Résultat integer

$lockCache protected_oe property

保存锁数据
protected array $lockCache
Résultat array

$useCache protected_oe property

锁驱动使用redis/memcache时使用的缓存
protected string $useCache
Résultat string