- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/data/cacheengine.php
- Класс: BitrixMainDataCacheEngine
- Вызов: CacheEngine::clean
public function clean($baseDir, $initDir = false, $filename = false)
{
if (!self::isAvailable())
{
return;
}
$baseDirVersion = $this->getBaseDirVersion($baseDir);
$initDirVersion = $this->getInitDirVersion($baseDir, $initDir);
$dir = sha1($baseDirVersion . '|' . $initDirVersion);
$initListKey = $this->sid . '|' .$dir . self::BX_DIR_LIST;
if ($this->fullClean)
{
$baseListKey = $this->sid . '|' .$baseDirVersion . self::BX_BASE_LIST;
}
if ($filename <> '')
{
$key = $this->sid . '|' .$dir . '|' . $filename;
$this->delFromSet($initListKey . $this->getPartition($filename), $filename);
if ($this->useLock && $cachedData = $this->get($key))
{
$this->set($key . '|old', $this->ttlOld, $cachedData);
}
$this->del($key);
if ($this->useLock)
{
$this->unlock($key);
}
}
elseif ($initDir != '')
{
$keyPrefix = $this->sid . '|' .$dir . '|';
$initDirKey = $this->getInitDirKey($baseDir, $initDir);
$this->del($initDirKey);
unset(static::$initDirVersion[$initDirKey]);
$partitionKeys = $this->getSet($initListKey);
foreach ($partitionKeys as $partition)
{
$delKey = $initListKey . $partition;
$this->deleteBySet($delKey, $keyPrefix);
$this->del($delKey);
if ($this->fullClean)
{
$this->delFromSet($baseListKey . $this->getPartition($delKey), $delKey);
}
}
$this->del($initListKey);
}
else
{
$baseDirKey = $this->sid . '|base_dir|' . sha1 ($baseDir);
$this->del($baseDirKey);
unset(static::$baseDirVersion[$baseDirKey]);
if ($this->fullClean)
{
$keyPrefix = $this->sid . '|' .$dir . '|';
$partitionKeys = $this->getSet($baseListKey);
foreach ($partitionKeys as $partition)
{
$baseListKeyPartition = $baseListKey . $partition;
$keys = $this->getSet($baseListKeyPartition);
foreach ($keys as $initKey)
{
$this->deleteBySet($initKey, $keyPrefix);
$this->del($initKey);
}
$this->del($baseListKeyPartition);
unset($keys);
}
$this->del($baseListKey);
}
}
}