• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/data/cacheenginexcache.php
  • Класс: BitrixMainDataCacheEngineXCache
  • Вызов: CacheEngineXCache::lock
protected function lock($baseDir, $initDir, $key, $TTL)
{
	if (
		isset(self::$locks[$baseDir])
		&& isset(self::$locks[$baseDir][$initDir])
		&& isset(self::$locks[$baseDir][$initDir][$key])
	)
	{
		return true;
	}
	elseif (xcache_get($key)) //another process has the lock
	{
		return false;
	}
	else
	{
		$lock = xcache_inc($key, 1, intval($TTL));
		if ($lock === 1) //we are lucky to be the first
		{
			self::$locks[$baseDir][$initDir][$key] = true;
			return true;
		}
		//xcache_dec have to be never called due to concurrency with xcache_set($key."~", 1, intval($TTL));
	}

	return false;
}