From db08da82138607acb71fb30adec19f55384f9974 Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Tue, 26 May 2020 13:53:10 +0200 Subject: [PATCH] Now try while flushing a selected database. --- .../Async/TaskStorage/RedisTaskStorage.php | 15 ++++++--------- test/config.tasks.php | 1 + 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/FuzeWorks/Async/TaskStorage/RedisTaskStorage.php b/src/FuzeWorks/Async/TaskStorage/RedisTaskStorage.php index 17402a2..8ebb22d 100644 --- a/src/FuzeWorks/Async/TaskStorage/RedisTaskStorage.php +++ b/src/FuzeWorks/Async/TaskStorage/RedisTaskStorage.php @@ -80,6 +80,9 @@ class RedisTaskStorage implements TaskStorage // Otherwise attempt authentication, if needed if (isset($parameters['password']) && !$this->conn->auth($parameters['password'])) throw new TasksException("Could not construct RedisTaskStorage. Authentication failure."); + + // And select the DB index + $this->conn->select($parameters['db_index']); } catch (RedisException $e) { throw new TasksException("Could not construct RedisTaskStorage. RedisException thrown: '" . $e->getMessage() . "'"); } @@ -282,7 +285,7 @@ class RedisTaskStorage implements TaskStorage { // First get the task ID $taskId = $task->getId(); - + // Check if the key already exists if (!$this->conn->exists($this->key_prefix . $taskId . '_post_' . $attempt)) return null; @@ -296,16 +299,10 @@ class RedisTaskStorage implements TaskStorage /** * @inheritDoc - * @throws TasksException */ public function reset(): bool { - // First get a list of all tasks - foreach ($this->readTasks() as $task) - $this->deleteTask($task); - - $this->refreshTasks(); - - return true; + // Clear the current db + return $this->conn->flushDB(); } } \ No newline at end of file diff --git a/test/config.tasks.php b/test/config.tasks.php index 81288f7..2ecf95a 100644 --- a/test/config.tasks.php +++ b/test/config.tasks.php @@ -68,6 +68,7 @@ return array( 'password' => Core::getEnv('TASKSTORAGE_REDIS_PASSWORD', null), 'port' => Core::getEnv('TASKSTORAGE_REDIS_PORT', 6379), 'timeout' => Core::getEnv('TASKSTORAGE_REDIS_TIMEOUT', 0), + 'db_index' => Core::getEnv('TASKSTORAGE_REDIS_DBINDEX', 0), ] ], 'Executor' => [