本文介绍了在单个服务器上为多个 Laravel 应用程序使用 Redis 队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个生产 laravel 应用程序和在同一台服务器上运行的暂存应用程序.我正在运行 redis,我将其用作队列驱动程序.它们显然连接到不同的数据库.问题是从登台应用程序推送到红色队列的作业是否会干扰生产数据库,反之亦然.

I have a production laravel application and the staging application running on the same server. I am running redis, which I am using as my queue driver. They are obviously connected to different databases. The question is if jobs that are pushed onto the reds queue from the staging application will interfere with the production db and vice versa.

推荐答案

您可以设置 Laravel 用于 Redis 缓存的前缀.默认情况下这是 laravel,所以所有的键都存储为 laravel:keyname 并且 Laravel 负责在保存/获取时添加/删除此前缀的逻辑.

You can set the prefix Laravel uses for the Redis cache. By default this is laravel, so all keys are stored as laravel:keyname and Laravel takes care of the logic to add/remove this prefix when saving/getting.

您可以在 config/cache.php 中设置前缀.您可以将主要的保留为 laravel 并将您的登台应用程序前缀设置为 stage 或其他东西.这意味着多个 Laravel 应用可以使用同一个 Redis 实例.

You can set the prefix in config/cache.php. You could leave the main one as laravel and set your staging app prefix to stage or something. This will mean multiple Laravel apps can use the same Redis instance.

这篇关于在单个服务器上为多个 Laravel 应用程序使用 Redis 队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 03:12