fix redis clear
This commit is contained in:
+10
-9
@@ -40,7 +40,7 @@ class Backup extends Command
|
|||||||
'database' => 0,
|
'database' => 0,
|
||||||
'username' => '',
|
'username' => '',
|
||||||
'password' => 'n1e5a6s6m7',
|
'password' => 'n1e5a6s6m7',
|
||||||
'useDocker' => false,
|
'useDocker' => true,
|
||||||
'dockerContainerName' => 'redis' // Docker 容器名称
|
'dockerContainerName' => 'redis' // Docker 容器名称
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -681,8 +681,12 @@ class Backup extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($redisSource && $redisSource['useDocker']) {
|
if (!$redisSource) {
|
||||||
// 使用 Docker 容器
|
$output->writeln("❌ 未找到 Redis 数据源配置");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($redisSource['useDocker']) {
|
||||||
$redisContainer = $redisSource['dockerContainerName'];
|
$redisContainer = $redisSource['dockerContainerName'];
|
||||||
if (!$redisContainer) {
|
if (!$redisContainer) {
|
||||||
$output->writeln("❌ 未指定 Redis Docker 容器名称");
|
$output->writeln("❌ 未指定 Redis Docker 容器名称");
|
||||||
@@ -701,12 +705,10 @@ class Backup extends Command
|
|||||||
$output->writeln(implode("\n", $outputLines));
|
$output->writeln(implode("\n", $outputLines));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 尝试使用 Redis 连接
|
|
||||||
$redis = new \Redis();
|
$redis = new \Redis();
|
||||||
$config = config('cache.stores.redis');
|
$host = $redisSource['host'] ?? '127.0.0.1';
|
||||||
$host = $config['host'] ?? '127.0.0.1';
|
$port = $redisSource['port'] ?? 6379;
|
||||||
$port = $config['port'] ?? 6379;
|
$password = $redisSource['password'] ?? '';
|
||||||
$password = $config['password'] ?? '';
|
|
||||||
|
|
||||||
$output->writeln("连接 Redis: {$host}:{$port}");
|
$output->writeln("连接 Redis: {$host}:{$port}");
|
||||||
|
|
||||||
@@ -715,7 +717,6 @@ class Backup extends Command
|
|||||||
$redis->auth($password);
|
$redis->auth($password);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清空 Redis
|
|
||||||
$result = $redis->flushAll();
|
$result = $redis->flushAll();
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
|
|||||||
Reference in New Issue
Block a user