diff --git a/src/Illuminate/Contracts/Queue/ClearableQueue.php b/src/Illuminate/Contracts/Queue/ClearableQueue.php
index 2f5c1ddd464b..427f61bf5ff7 100644
--- a/src/Illuminate/Contracts/Queue/ClearableQueue.php
+++ b/src/Illuminate/Contracts/Queue/ClearableQueue.php
@@ -5,7 +5,7 @@
interface ClearableQueue
{
/**
- * Clear all jobs from the queue.
+ * Delete all of the jobs from the queue.
*
* @param string $queue
* @return int
diff --git a/src/Illuminate/Queue/Console/ClearCommand.php b/src/Illuminate/Queue/Console/ClearCommand.php
index a5ff18a48607..55b5b4a0d5dd 100644
--- a/src/Illuminate/Queue/Console/ClearCommand.php
+++ b/src/Illuminate/Queue/Console/ClearCommand.php
@@ -25,7 +25,7 @@ class ClearCommand extends Command
*
* @var string
*/
- protected $description = 'Clear the queue';
+ protected $description = 'Delete all of the jobs from the specified queue';
/**
* Execute the console command.
@@ -45,14 +45,15 @@ public function handle()
// configuration file for the application. We will pull it based on the set
// connection being run for the queue operation currently being executed.
$queueName = $this->getQueue($connection);
+
$queue = ($this->laravel['queue'])->connection($connection);
if ($queue instanceof ClearableQueue) {
$count = $queue->clear($queueName);
- $this->line('Cleared '.$count.' jobs from the '.$queueName.' queue ');
+ $this->line('Cleared '.$count.' jobs from the ['.$queueName.'] queue ');
} else {
- $this->line('Clearing queues is not supported on '.(new ReflectionClass($queue))->getShortName().' ');
+ $this->line('Clearing queues is not supported on ['.(new ReflectionClass($queue))->getShortName().'] ');
}
return 0;
diff --git a/src/Illuminate/Queue/DatabaseQueue.php b/src/Illuminate/Queue/DatabaseQueue.php
index 313c575774e4..c18de9cc16f3 100644
--- a/src/Illuminate/Queue/DatabaseQueue.php
+++ b/src/Illuminate/Queue/DatabaseQueue.php
@@ -304,19 +304,6 @@ protected function markJobAsReserved($job)
return $job;
}
- /**
- * Clear all jobs from the queue.
- *
- * @param string $queue
- * @return int
- */
- public function clear($queue)
- {
- return $this->database->table($this->table)
- ->where('queue', $this->getQueue($queue))
- ->delete();
- }
-
/**
* Delete a reserved job from the queue.
*
@@ -354,6 +341,19 @@ public function deleteAndRelease($queue, $job, $delay)
});
}
+ /**
+ * Delete all of the jobs from the queue.
+ *
+ * @param string $queue
+ * @return int
+ */
+ public function clear($queue)
+ {
+ return $this->database->table($this->table)
+ ->where('queue', $this->getQueue($queue))
+ ->delete();
+ }
+
/**
* Get the queue or return the default.
*
diff --git a/src/Illuminate/Queue/LuaScripts.php b/src/Illuminate/Queue/LuaScripts.php
index 447c759c4d58..c592ae3dbd75 100644
--- a/src/Illuminate/Queue/LuaScripts.php
+++ b/src/Illuminate/Queue/LuaScripts.php
@@ -20,24 +20,6 @@ public static function size()
LUA;
}
- /**
- * Get the Lua script for clearing the queue.
- *
- * KEYS[1] - The name of the primary queue
- * KEYS[2] - The name of the "delayed" queue
- * KEYS[3] - The name of the "reserved" queue
- *
- * @return string
- */
- public static function clear()
- {
- return <<<'LUA'
-local size = redis.call('llen', KEYS[1]) + redis.call('zcard', KEYS[2]) + redis.call('zcard', KEYS[3])
-redis.call('del', KEYS[1], KEYS[2], KEYS[3])
-return size
-LUA;
- }
-
/**
* Get the Lua script for pushing jobs onto the queue.
*
@@ -142,6 +124,24 @@ public static function migrateExpiredJobs()
end
return val
+LUA;
+ }
+
+ /**
+ * Get the Lua script for removing all jobs from the queue.
+ *
+ * KEYS[1] - The name of the primary queue
+ * KEYS[2] - The name of the "delayed" queue
+ * KEYS[3] - The name of the "reserved" queue
+ *
+ * @return string
+ */
+ public static function clear()
+ {
+ return <<<'LUA'
+local size = redis.call('llen', KEYS[1]) + redis.call('zcard', KEYS[2]) + redis.call('zcard', KEYS[3])
+redis.call('del', KEYS[1], KEYS[2], KEYS[3])
+return size
LUA;
}
}
diff --git a/src/Illuminate/Queue/RedisQueue.php b/src/Illuminate/Queue/RedisQueue.php
index 593a5a3a9f42..56bfbd5e46b9 100644
--- a/src/Illuminate/Queue/RedisQueue.php
+++ b/src/Illuminate/Queue/RedisQueue.php
@@ -257,21 +257,6 @@ protected function retrieveNextJob($queue, $block = true)
return [$job, $reserved];
}
- /**
- * Clear all jobs from the queue.
- *
- * @param string $queue
- * @return int
- */
- public function clear($queue)
- {
- $queue = $this->getQueue($queue);
-
- return $this->getConnection()->eval(
- LuaScripts::clear(), 3, $queue, $queue.':delayed', $queue.':reserved'
- );
- }
-
/**
* Delete a reserved job from the queue.
*
@@ -302,6 +287,21 @@ public function deleteAndRelease($queue, $job, $delay)
);
}
+ /**
+ * Delete all of the jobs from the queue.
+ *
+ * @param string $queue
+ * @return int
+ */
+ public function clear($queue)
+ {
+ $queue = $this->getQueue($queue);
+
+ return $this->getConnection()->eval(
+ LuaScripts::clear(), 3, $queue, $queue.':delayed', $queue.':reserved'
+ );
+ }
+
/**
* Get a random ID string.
*