Начало работы с redis, попытки сделать SOLIDно

This commit is contained in:
vasya
2026-04-11 22:50:52 +03:00
parent ef388bfa2a
commit 8a371d05b0
3 changed files with 67 additions and 40 deletions
+15
View File
@@ -0,0 +1,15 @@
<?php
namespace App\Facades;
use Illuminate\Support\Facades\Facade;
use App\Services\RedisNotificationService;
class RedisNotifications extends Facade
{
protected static function getFacadeAccessor()
{
return \App\Services\RedisNotificationService::class;
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Providers;
use App\Services\RedisNotificationService;
use Illuminate\Support\ServiceProvider;
/**
* Провайдер для работы с сервисом Redis для хранения нотификаций для отображения на фронте
*/
class RedisNotificationProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
$this->app->bind(RedisNotificationService::class, function($app){
return new RedisNotificationService;
});
}
/**
* Bootstrap services.
*/
public function boot(): void
{
//
}
}
+22 -40
View File
@@ -7,25 +7,24 @@ return [
| Default Queue Connection Name | Default Queue Connection Name
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Laravel's queue supports a variety of backends via a single, unified | Laravel's queue API supports an assortment of back-ends via a single
| API, giving you convenient access to each backend using identical | API, giving you convenient access to each back-end using the same
| syntax for each. The default queue connection is defined below. | syntax for every one. Here you may define a default connection.
| |
*/ */
'default' => env('QUEUE_CONNECTION', 'database'), 'default' => env('QUEUE_CONNECTION', 'sync'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Queue Connections | Queue Connections
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Here you may configure the connection options for every queue backend | Here you may configure the connection information for each server that
| used by your application. An example configuration is provided for | is used by your application. A default configuration has been added
| each backend supported by Laravel. You're also free to add more. | for each back-end shipped with Laravel. You are free to add more.
| |
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
| "deferred", "background", "failover", "null"
| |
*/ */
@@ -37,18 +36,17 @@ return [
'database' => [ 'database' => [
'driver' => 'database', 'driver' => 'database',
'connection' => env('DB_QUEUE_CONNECTION'), 'table' => 'jobs',
'table' => env('DB_QUEUE_TABLE', 'jobs'), 'queue' => 'default',
'queue' => env('DB_QUEUE', 'default'), 'retry_after' => 90,
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
'after_commit' => false, 'after_commit' => false,
], ],
'beanstalkd' => [ 'beanstalkd' => [
'driver' => 'beanstalkd', 'driver' => 'beanstalkd',
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'), 'host' => 'localhost',
'queue' => env('BEANSTALKD_QUEUE', 'default'), 'queue' => 'default',
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90), 'retry_after' => 90,
'block_for' => 0, 'block_for' => 0,
'after_commit' => false, 'after_commit' => false,
], ],
@@ -64,31 +62,17 @@ return [
'after_commit' => false, 'after_commit' => false,
], ],
#Гаврилов
//ЗАЧЕМ ЭТОТ КОНФИГ? В .ENV НЕТ ПАРАМЕТРА REDIS_QUEUE
'redis' => [ 'redis' => [
'driver' => 'redis', 'driver' => 'redis',
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'), 'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'), 'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90), 'retry_after' => 90,
'block_for' => null, 'block_for' => null,
'after_commit' => false, 'after_commit' => false,
], ],
'deferred' => [
'driver' => 'deferred',
],
'background' => [
'driver' => 'background',
],
'failover' => [
'driver' => 'failover',
'connections' => [
'database',
'deferred',
],
],
], ],
/* /*
@@ -103,7 +87,7 @@ return [
*/ */
'batching' => [ 'batching' => [
'database' => env('DB_CONNECTION', 'sqlite'), 'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'job_batches', 'table' => 'job_batches',
], ],
@@ -113,16 +97,14 @@ return [
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| These options configure the behavior of failed queue job logging so you | These options configure the behavior of failed queue job logging so you
| can control how and where failed jobs are stored. Laravel ships with | can control which database and table are used to store the jobs that
| support for storing failed jobs in a simple file or in a database. | have failed. You may change them to any database / table you wish.
|
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
| |
*/ */
'failed' => [ 'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'sqlite'), 'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs', 'table' => 'failed_jobs',
], ],