diff --git a/.env.example b/.env.example
index f7bac5a6..e29ec316 100644
--- a/.env.example
+++ b/.env.example
@@ -66,7 +66,7 @@ MAIL_ENCRYPTION = null
# Change below lines only if you know what they mean!
CACHE_DRIVER = file
SESSION_DRIVER = file
-QUEUE_DRIVER = sync
+QUEUE_DRIVER = database
REDIS_HOST = 127.0.0.1
REDIS_PASSWORD = null
diff --git a/app/Notifications/SiteMessage.php b/app/Notifications/SiteMessage.php
index d62a84ae..eff97f24 100644
--- a/app/Notifications/SiteMessage.php
+++ b/app/Notifications/SiteMessage.php
@@ -4,10 +4,14 @@ declare(strict_types=1);
namespace App\Notifications;
+use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
+use Illuminate\Contracts\Queue\ShouldQueue;
-class SiteMessage extends Notification
+class SiteMessage extends Notification implements ShouldQueue
{
+ use Queueable;
+
public $title;
public $content;
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 15c99c68..afb7ffc9 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -50,8 +50,11 @@ class AppServiceProvider extends ServiceProvider
try {
if (option('enable_redis') && Redis::ping()) {
- config(['cache.default' => 'redis']);
- config(['session.driver' => 'redis']);
+ config([
+ 'cache.default' => 'redis',
+ 'session.driver' => 'redis',
+ 'queue.default' => 'redis',
+ ]);
}
} catch (\Exception $e) {
//
diff --git a/config/queue.php b/config/queue.php
index d0f732a6..7a8e1237 100644
--- a/config/queue.php
+++ b/config/queue.php
@@ -15,7 +15,7 @@ return [
|
*/
- 'default' => env('QUEUE_DRIVER', 'sync'),
+ 'default' => env('QUEUE_DRIVER', 'database'),
/*
|--------------------------------------------------------------------------
diff --git a/database/migrations/2019_07_05_222912_create_jobs_table.php b/database/migrations/2019_07_05_222912_create_jobs_table.php
new file mode 100644
index 00000000..58d77154
--- /dev/null
+++ b/database/migrations/2019_07_05_222912_create_jobs_table.php
@@ -0,0 +1,36 @@
+bigIncrements('id');
+ $table->string('queue')->index();
+ $table->longText('payload');
+ $table->unsignedTinyInteger('attempts');
+ $table->unsignedInteger('reserved_at')->nullable();
+ $table->unsignedInteger('available_at');
+ $table->unsignedInteger('created_at');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('jobs');
+ }
+}
diff --git a/database/update_scripts/update-4.3.6-to-4.3.7.php b/database/update_scripts/update-4.3.6-to-4.3.7.php
new file mode 100644
index 00000000..2d9a4803
--- /dev/null
+++ b/database/update_scripts/update-4.3.6-to-4.3.7.php
@@ -0,0 +1,10 @@
+php artisan migrate --force',
+ '',
+ '然后修改 .env 文件,将 QUEUE_DRIVER 的值改为 database。(使用 Redis 的用户请修改为 redis)',
+ 'Then, please edit your ".env" file. Change the value of QUEUE_DRIVER from sync to database. Redis users please change it to redis.',
+];
diff --git a/resources/misc/changelogs/en/4.3.7.md b/resources/misc/changelogs/en/4.3.7.md
new file mode 100644
index 00000000..0a69f780
--- /dev/null
+++ b/resources/misc/changelogs/en/4.3.7.md
@@ -0,0 +1,3 @@
+## Tweaked
+
+- Push notifications to queue for performance.
diff --git a/resources/misc/changelogs/zh_CN/4.3.7.md b/resources/misc/changelogs/zh_CN/4.3.7.md
new file mode 100644
index 00000000..dd16ca5f
--- /dev/null
+++ b/resources/misc/changelogs/zh_CN/4.3.7.md
@@ -0,0 +1,3 @@
+## 调整
+
+- 发送通知时将任务推送到队列
diff --git a/tests/SetupControllerTest.php b/tests/SetupControllerTest.php
index db339af9..afe8a68e 100644
--- a/tests/SetupControllerTest.php
+++ b/tests/SetupControllerTest.php
@@ -41,6 +41,7 @@ class SetupControllerTest extends TestCase
'oauth_personal_access_clients',
'oauth_refresh_tokens',
'notifications',
+ 'jobs',
];
array_walk($tables, function ($table) {
Schema::dropIfExists($table);