PHP Class Cml\Lock

Show file Open project: linhecheng/cmlphp Class Usage Examples

Public Methods

Method Description
getLocker ( string | null $useCache = null ) : Redis 获取Lock实例
lock ( string $key, boolean $wouldBlock = false ) : mixed 上锁
setExpire ( integer $expire = 100 ) : Redis 设置锁的过期时间
unlock ( string $key ) : void 解锁

Method Details

getLocker() public static method

获取Lock实例
public static getLocker ( string | null $useCache = null ) : Redis
$useCache string | null 使用的锁的配置
return Cml\Lock\Redis | \Cml\Lock\Memcache | \Cml\Lock\File | false

lock() public static method

上锁
public static lock ( string $key, boolean $wouldBlock = false ) : mixed
$key string 要解锁的锁的key
$wouldBlock boolean 是否堵塞
return mixed

setExpire() public static method

设置锁的过期时间
public static setExpire ( integer $expire = 100 ) : Redis
$expire integer
return Cml\Lock\Redis | \Cml\Lock\Memcache | \Cml\Lock\File

unlock() public static method

解锁
public static unlock ( string $key ) : void
$key string
return void