-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
# laravel-redis-queue | ||
# Laravel Redis Queue | ||
|
||
A little command line tool for clearing Laravel redis queues. | ||
|
||
## Basic Clear | ||
|
||
This command clears the redis queue defined in your `config/queue.php` file. The configuration is normally set to `default`. | ||
|
||
```shell | ||
php artisan queue:redis -C | ||
``` | ||
|
||
Outputs, | ||
|
||
``` | ||
Clearing Redis queues:default | ||
``` | ||
|
||
## Defined Queue Clear | ||
|
||
To clear a defined queue specify it in the artisan command as an augument. | ||
|
||
```shell | ||
php artisan queue:redis emails -C | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "kevindees/laravel-redis-queue", | ||
"description": "Redis queue managment for laravel.", | ||
"keywords": ["laravel", "queue", "redis"], | ||
"license": "MIT", | ||
"require": { | ||
"php": "^7.0", | ||
"predis/predis": "^1.1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"QueueRedis\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"QueueRedis\\QueueRedisServiceProvider" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
<?php | ||
namespace QueueRedis; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\Redis; | ||
|
||
class QueueRedisCommand extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'queue:redis | ||
{queue? : The queue you wish to target} | ||
{--C|clear : Clear the queue}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Flush redis queue'; | ||
|
||
protected $queue; | ||
protected $clear; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$this->queue = $this->argument('queue') ?: config('queue.connections.redis.queue'); | ||
$this->clear = $this->option('clear'); | ||
|
||
if($this->clear) { | ||
$this->clear(); | ||
} | ||
} | ||
|
||
protected function clear() { | ||
$del = 'queues:' . escapeshellcmd($this->queue); | ||
$this->info('Clearing Redis ' . $del); | ||
Redis::connection()->del($del); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace QueueRedis; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class QueueRedisServiceProvider extends ServiceProvider { | ||
|
||
/** | ||
* Register bindings in the container. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
} | ||
|
||
/** | ||
* Bootstrap the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
if ($this->app->runningInConsole()) { | ||
$this->commands([ | ||
QueueRedisCommand::class, | ||
]); | ||
} | ||
} | ||
} |