本文整理汇总了PHP中JCache::lock方法的典型用法代码示例。如果您正苦于以下问题:PHP JCache::lock方法的具体用法?PHP JCache::lock怎么用?PHP JCache::lock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JCache
的用法示例。
在下文中一共展示了JCache::lock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store data to cache by ID and group
*
* @param mixed $data The data to store
* @param string $id The cache data ID
* @param string $group The cache data group
* @param boolean $wrkarounds True to use wrkarounds
*
* @return boolean True if cache stored
*
* @since 11.1
*/
public function store($data, $id, $group = null, $wrkarounds = true)
{
$locktest = $this->cache->lock($id, $group);
if ($locktest->locked == false && $locktest->locklooped == true) {
$locktest = $this->cache->lock($id, $group);
}
$success = $this->cache->store(serialize($data), $id, $group);
if ($locktest->locked == true) {
$this->cache->unlock($id, $group);
}
return $success;
}
示例2: store
/**
* Store data to cache by id and group
*
* @param mixed $data The data to store
* @param string $id The cache data id
* @param string $group The cache data group
*
* @return boolean True if cache was stored
*
* @since 11.1
*/
public function store($data, $id, $group = null)
{
$locktest = new stdClass();
$locktest->locked = null;
$locktest->locklooped = null;
$locktest = $this->cache->lock($id, $group);
if ($locktest->locked == false && $locktest->locklooped == true) {
$locktest = $this->cache->lock($id, $group);
}
$sucess = $this->cache->store(serialize($data), $id, $group);
if ($locktest->locked == true) {
$this->cache->unlock($id, $group);
}
return $sucess;
}