公共方法
This commit is contained in:
@@ -34,9 +34,12 @@ class QueueRedis
|
||||
$this->config['host'] ?? '127.0.0.1',
|
||||
$this->config['port'] ?? 6379
|
||||
);
|
||||
|
||||
// 始终执行认证(空密码会被 Redis 忽略)
|
||||
$this->redis->auth($this->config['password'] ?? '');
|
||||
if (!empty($this->config['password'])) {
|
||||
$this->redis->auth($this->config['password']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->redis->select($this->config['select'] ?? 0);
|
||||
}
|
||||
@@ -149,7 +152,7 @@ LUA;
|
||||
'completed' => 0,
|
||||
'start_time' => time()
|
||||
]);
|
||||
$redis->expire($key, 21600); // 6小时过期
|
||||
$redis->expire($key, 10800); // 6小时过期
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
@@ -185,7 +188,7 @@ LUA;
|
||||
$redis = $this->connect();
|
||||
$redis->hSet($key, "chunk_{$chunkIndex}", $content);
|
||||
// 确保设置过期时间(如果已设置则忽略)
|
||||
$redis->expire($key, 21600);
|
||||
$redis->expire($key, 10800);
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -202,7 +205,7 @@ LUA;
|
||||
public function getConnectionStatus()
|
||||
{
|
||||
try {
|
||||
return $this->connect()->ping() === '+PONG';
|
||||
return $this->connect()->ping();
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user