Skip to content

Update queues.md #709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions queues.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
git: e6614cccb4af772862d5d666e7b7ad9878790765
git: 7af3c41df42294ab469d698189975fa087a3c21a
---

# Очереди
Expand Down Expand Up @@ -63,7 +63,7 @@ php artisan migrate

**Кластер Redis**

Если ваше соединение с очередью Redis использует кластер Redis, то имена ваших очередей должны содержать [ключевой хеш-тег](https://redis.io/docs/reference/cluster-spec/#hash-tags). Это необходимо для того, чтобы все ключи Redis для указанной очереди были поставлены в один и тот же хеш-слот:
Если ваше соединение с очередью Redis использует [кластер Redis](https://redis.io/docs/latest/operate/rs/databases/durability-ha/clustering), то имена ваших очередей должны содержать [ключевой хеш-тег](https://redis.io/docs/latest/develop/using-commands/keyspace/#hashtags). Это необходимо для того, чтобы все ключи Redis для указанной очереди были поставлены в один и тот же хеш-слот:

```php
'redis' => [
Expand Down Expand Up @@ -219,6 +219,34 @@ public function __construct(
) {}
```

Для удобства, если вы хотите сериализовать все модели без связей, вы можете применить атрибут `WithoutRelations` ко всему классу вместо того, чтобы применять атрибут к каждой модели:

```php
<?php

namespace App\Jobs;

use App\Models\DistributionPlatform;
use App\Models\Podcast;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Queue\Attributes\WithoutRelations;

#[WithoutRelations]
class ProcessPodcast implements ShouldQueue
{
use Queueable;

/**
* Create a new job instance.
*/
public function __construct(
public Podcast $podcast,
public DistributionPlatform $platform,
) {}
}
```

Если задание получает коллекцию или массив моделей Eloquent вместо одной модели, отношения между моделями в этой коллекции не будут восстановлены при десериализации и выполнении задания. Это необходимо для предотвращения чрезмерного использования ресурсов в заданиях, связанных с большим количеством моделей.

<a name="unique-jobs"></a>
Expand Down Expand Up @@ -248,7 +276,8 @@ class UpdateSearchIndex implements ShouldQueue, ShouldBeUnique
```php
<?php

use App\Models\Product;
namespace App\Jobs;

use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Queue\ShouldBeUnique;

Expand All @@ -257,7 +286,7 @@ class UpdateSearchIndex implements ShouldQueue, ShouldBeUnique
/**
* Экземпляр продукта.
*
* @var \App\Product
* @var \App\Models\Product
*/
public $product;

Expand Down Expand Up @@ -291,7 +320,6 @@ class UpdateSearchIndex implements ShouldQueue, ShouldBeUnique
```php
<?php

use App\Models\Product;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;

Expand Down