Skip to content

Commit 06b378c

Browse files
committed
formatting
1 parent 452826b commit 06b378c

File tree

5 files changed

+51
-50
lines changed

5 files changed

+51
-50
lines changed

src/Illuminate/Contracts/Queue/ClearableQueue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
interface ClearableQueue
66
{
77
/**
8-
* Clear all jobs from the queue.
8+
* Delete all of the jobs from the queue.
99
*
1010
* @param string $queue
1111
* @return int

src/Illuminate/Queue/Console/ClearCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ClearCommand extends Command
2525
*
2626
* @var string
2727
*/
28-
protected $description = 'Clear the queue';
28+
protected $description = 'Delete all of the jobs from the specified queue';
2929

3030
/**
3131
* Execute the console command.
@@ -45,14 +45,15 @@ public function handle()
4545
// configuration file for the application. We will pull it based on the set
4646
// connection being run for the queue operation currently being executed.
4747
$queueName = $this->getQueue($connection);
48+
4849
$queue = ($this->laravel['queue'])->connection($connection);
4950

5051
if ($queue instanceof ClearableQueue) {
5152
$count = $queue->clear($queueName);
5253

53-
$this->line('<info>Cleared '.$count.' jobs from the '.$queueName.' queue</info> ');
54+
$this->line('<info>Cleared '.$count.' jobs from the ['.$queueName.'] queue</info> ');
5455
} else {
55-
$this->line('<error>Clearing queues is not supported on '.(new ReflectionClass($queue))->getShortName().'</error> ');
56+
$this->line('<error>Clearing queues is not supported on ['.(new ReflectionClass($queue))->getShortName().']</error> ');
5657
}
5758

5859
return 0;

src/Illuminate/Queue/DatabaseQueue.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -304,19 +304,6 @@ protected function markJobAsReserved($job)
304304
return $job;
305305
}
306306

307-
/**
308-
* Clear all jobs from the queue.
309-
*
310-
* @param string $queue
311-
* @return int
312-
*/
313-
public function clear($queue)
314-
{
315-
return $this->database->table($this->table)
316-
->where('queue', $this->getQueue($queue))
317-
->delete();
318-
}
319-
320307
/**
321308
* Delete a reserved job from the queue.
322309
*
@@ -354,6 +341,19 @@ public function deleteAndRelease($queue, $job, $delay)
354341
});
355342
}
356343

344+
/**
345+
* Delete all of the jobs from the queue.
346+
*
347+
* @param string $queue
348+
* @return int
349+
*/
350+
public function clear($queue)
351+
{
352+
return $this->database->table($this->table)
353+
->where('queue', $this->getQueue($queue))
354+
->delete();
355+
}
356+
357357
/**
358358
* Get the queue or return the default.
359359
*

src/Illuminate/Queue/LuaScripts.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,6 @@ public static function size()
2020
LUA;
2121
}
2222

23-
/**
24-
* Get the Lua script for clearing the queue.
25-
*
26-
* KEYS[1] - The name of the primary queue
27-
* KEYS[2] - The name of the "delayed" queue
28-
* KEYS[3] - The name of the "reserved" queue
29-
*
30-
* @return string
31-
*/
32-
public static function clear()
33-
{
34-
return <<<'LUA'
35-
local size = redis.call('llen', KEYS[1]) + redis.call('zcard', KEYS[2]) + redis.call('zcard', KEYS[3])
36-
redis.call('del', KEYS[1], KEYS[2], KEYS[3])
37-
return size
38-
LUA;
39-
}
40-
4123
/**
4224
* Get the Lua script for pushing jobs onto the queue.
4325
*
@@ -142,6 +124,24 @@ public static function migrateExpiredJobs()
142124
end
143125
144126
return val
127+
LUA;
128+
}
129+
130+
/**
131+
* Get the Lua script for removing all jobs from the queue.
132+
*
133+
* KEYS[1] - The name of the primary queue
134+
* KEYS[2] - The name of the "delayed" queue
135+
* KEYS[3] - The name of the "reserved" queue
136+
*
137+
* @return string
138+
*/
139+
public static function clear()
140+
{
141+
return <<<'LUA'
142+
local size = redis.call('llen', KEYS[1]) + redis.call('zcard', KEYS[2]) + redis.call('zcard', KEYS[3])
143+
redis.call('del', KEYS[1], KEYS[2], KEYS[3])
144+
return size
145145
LUA;
146146
}
147147
}

src/Illuminate/Queue/RedisQueue.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -257,21 +257,6 @@ protected function retrieveNextJob($queue, $block = true)
257257
return [$job, $reserved];
258258
}
259259

260-
/**
261-
* Clear all jobs from the queue.
262-
*
263-
* @param string $queue
264-
* @return int
265-
*/
266-
public function clear($queue)
267-
{
268-
$queue = $this->getQueue($queue);
269-
270-
return $this->getConnection()->eval(
271-
LuaScripts::clear(), 3, $queue, $queue.':delayed', $queue.':reserved'
272-
);
273-
}
274-
275260
/**
276261
* Delete a reserved job from the queue.
277262
*
@@ -302,6 +287,21 @@ public function deleteAndRelease($queue, $job, $delay)
302287
);
303288
}
304289

290+
/**
291+
* Delete all of the jobs from the queue.
292+
*
293+
* @param string $queue
294+
* @return int
295+
*/
296+
public function clear($queue)
297+
{
298+
$queue = $this->getQueue($queue);
299+
300+
return $this->getConnection()->eval(
301+
LuaScripts::clear(), 3, $queue, $queue.':delayed', $queue.':reserved'
302+
);
303+
}
304+
305305
/**
306306
* Get a random ID string.
307307
*

0 commit comments

Comments
 (0)