Search code examples
laravelredisqueue

Using Redis for Queues for Multiple Laravel Applications on a Single Server


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.


Solution

  • 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.

    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.