Подробная информация:
raveler version: 10.0.3
redis client: phpredis
redis версия: 7.4.1
Prefix кэша: laravel_cache_solar_cache
Для проекта мы используем контейнеры Docker, Redis находится в отдельном контейнере, но я не думаю, что это проблема.
Код: Выделить всё
laravel_cache_solar_cache:v1/verticals-menu:userId:4:b6f331f8f609d4bf3e9f4568bd69aacba4e464aa
Когда я пытаюсь удалить его с помощью подключения Laravel's Redis:
Код: Выделить всё
$connection->del($key);
foreach ($this->clusterConnectionNames as $clusterConnectionName) {
try {
$this->logService->info("Processing crossClusterFlushByKeys for cluster '$clusterConnectionName'");
/** @var RedisStore $store */
$store = Cache::store($clusterConnectionName)->getStore();
/** @var PhpRedisConnection $connection **/
$connection = $store->connection();
// Retrieve Redis prefixes from configuration
$prefix = Config::get('database.redis.options.prefix');
$cachePrefix = $store->getPrefix();
$scanPatternBase = $prefix . $cachePrefix;
// Initialize a counter for the total number of keys deleted in this cluster
$totalDeleted = 0;
foreach ($keysForDeletion as $baseKey) {
$matchPattern = $scanPatternBase . $baseKey . "*";
$cursor = null;
do {
$scanResult = $connection->scan($cursor, [
'match' => $matchPattern,
'count' => 1000
]);
if ($scanResult === false) {
$this->logService->warning("SCAN command failed for pattern '$matchPattern' on cluster '$clusterConnectionName'");
break;
}
[$cursor, $matches] = $scanResult;
if (!empty($matches)) {
$this->logService->info("Deleting " . count($matches) . " keys from cluster '$clusterConnectionName'", [
'keys' => $matches
]);
foreach ($matches as $key) {
$connection->executeRaw(['DEL', $key]);
}
}
} while ($cursor != 0);
}
$this->logService->info("Total keys deleted from cluster '$clusterConnectionName': $totalDeleted");
< /code>
Эта реализация работает, но если мы используем $ connection-> del ($ key); Это не удаляет ключ.
Подробнее здесь: https://stackoverflow.com/questions/794 ... rawdel-key