This commit is contained in:
root
2025-11-13 19:52:28 +03:00
parent 8aeeb05b7d
commit 807dec3b6c
4646 changed files with 163445 additions and 626017 deletions

View File

@@ -9,6 +9,7 @@ use Bitrix\Main\Data\Cache;
use Bitrix\Main\Data\CacheEngineInterface;
use Bitrix\Main\Data\CacheEngineStatInterface;
use Bitrix\Main\Data\Internal\CacheCleanPathTable;
use Bitrix\Main\Type\DateTime;
abstract class KeyValueEngine implements CacheEngineInterface, CacheEngineStatInterface
{
@@ -151,7 +152,7 @@ abstract class KeyValueEngine implements CacheEngineInterface, CacheEngineStatIn
{
$this->sid = $cacheConfig['sid'];
}
$this->sid .= '|v1';
$this->sid .= '|v1.1';
if (isset($cacheConfig['actual_data']) && !$this->useLock)
{
@@ -289,7 +290,7 @@ abstract class KeyValueEngine implements CacheEngineInterface, CacheEngineStatIn
protected function getPartition($key): string
{
return substr(sha1($key), 0, 2);
return substr(sha1($key), 0, 4);
}
protected function getInitDirKey($baseDirVersion, $baseDir, $initDir): string
@@ -315,7 +316,7 @@ abstract class KeyValueEngine implements CacheEngineInterface, CacheEngineStatIn
* @param bool $create
* @return string
*/
protected function getInitDirVersion($baseDir, $initDir = false, bool $create = true ): string
protected function getInitDirVersion($baseDir, $initDir = false, bool $create = true): string
{
$baseDirVersion = $this->getBaseDirVersion($baseDir);
$initDirHash = sha1($baseDir . '|' . $initDir);
@@ -523,11 +524,11 @@ abstract class KeyValueEngine implements CacheEngineInterface, CacheEngineStatIn
if ($this->useLock)
{
$this->set($key . '~', $this->ttlOld, $initDirVersion);
$cleanFrom = (new \Bitrix\Main\Type\DateTime())->add('+' . $this->ttlOld . ' seconds');
$cleanFrom = (new DateTime())->add('+' . $this->ttlOld . ' seconds');
}
else
{
$cleanFrom = (new \Bitrix\Main\Type\DateTime());
$cleanFrom = (new DateTime());
}
$this->addCleanPath([
@@ -557,7 +558,7 @@ abstract class KeyValueEngine implements CacheEngineInterface, CacheEngineStatIn
{
$this->addCleanPath([
'PREFIX' => $path,
'CLEAN_FROM' => (new \Bitrix\Main\Type\DateTime()),
'CLEAN_FROM' => (new DateTime()),
'CLUSTER_GROUP' => static::$clusterGroup
]);
}
@@ -601,7 +602,7 @@ abstract class KeyValueEngine implements CacheEngineInterface, CacheEngineStatIn
$paths = CacheCleanPathTable::query()
->setSelect(['ID', 'PREFIX'])
->where('CLEAN_FROM', '<=', new \Bitrix\Main\Type\DateTime())
->where('CLEAN_FROM', '<=', new DateTime())
->where('CLUSTER_GROUP', static::$clusterGroup)
->setLimit($count + $delta)
->exec();

View File

@@ -25,8 +25,8 @@ class CacheEngineRedisLight extends CacheEngineRedis
if ($filename <> '')
{
$key = $keyPrefix . '|' . $filename;
$this->delFromSet($initListKey, $filename);
$this->del($key);
$this->delFromSet($initListKey, $filename);
}
elseif ($initDir != '')
{

View File

@@ -22,8 +22,10 @@ class CacheStorage implements StorageInterface
public function read(string $key, int $ttl)
{
$filename = '/' . Cache::getPath($key);
if ($this->cacheEngine->read($value, $this->baseDir, self::CACHE_DIR, $filename, $ttl))
$initDir = $this->getDirname($key);
$filename = $this->getFilename($key);
if ($this->cacheEngine->read($value, $this->baseDir, $initDir, $filename, $ttl))
{
return $value;
}
@@ -33,7 +35,19 @@ class CacheStorage implements StorageInterface
public function write(string $key, $value, int $ttl)
{
$filename = '/' . Cache::getPath($key);
$this->cacheEngine->write($value, $this->baseDir, self::CACHE_DIR, $filename, $ttl);
$initDir = $this->getDirname($key);
$filename = $this->getFilename($key);
$this->cacheEngine->write($value, $this->baseDir, $initDir, $filename, $ttl);
}
private function getDirname(string $key): string
{
return self::CACHE_DIR . '/'. substr(md5($key), 0, 3);
}
private function getFilename(string $key): string
{
return '/' . Cache::getPath($key);
}
}

View File

@@ -1,9 +1,10 @@
<?php
/**
* Bitrix Framework
* @package bitrix
* @subpackage main
* @copyright 2001-2024 Bitrix
* @copyright 2001-2025 Bitrix
*/
namespace Bitrix\Main\Data;
@@ -193,18 +194,18 @@ class TaggedCache
protected function deleteTags(Cache $cache, array $id, array $paths): void
{
CacheTagTable::deleteByFilter(['@ID' => $id]);
CacheTagTable::deleteByFilter(['@RELATIVE_PATH' => array_keys($paths)]);
foreach ($paths as $path => $v)
{
$cache->cleanDir($path);
unset($this->cacheTag[$path]);
}
CacheTagTable::deleteByFilter(['@ID' => $id]);
CacheTagTable::deleteByFilter(['@RELATIVE_PATH' => array_keys($paths)]);
}
public function deleteAllTags(): void
{
CacheTagTable::cleanTable();
}
}
}