diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1f1025f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index 7cf52a9..2f4a318 100644 --- a/README.md +++ b/README.md @@ -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 ``` \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..a6edcf3 --- /dev/null +++ b/composer.json @@ -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" + ] + } + } +} diff --git a/src/QueueRedisCommand.php b/src/QueueRedisCommand.php new file mode 100644 index 0000000..e0879be --- /dev/null +++ b/src/QueueRedisCommand.php @@ -0,0 +1,59 @@ + +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); + } +} diff --git a/src/QueueRedisServiceProvider.php b/src/QueueRedisServiceProvider.php new file mode 100644 index 0000000..fdaf194 --- /dev/null +++ b/src/QueueRedisServiceProvider.php @@ -0,0 +1,31 @@ +app->runningInConsole()) { + $this->commands([ + QueueRedisCommand::class, + ]); + } + } +} \ No newline at end of file