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.
One reason that Redis is optimal for queuing tasks is that it offers atomic operations, meaning that any mutations to data are performed immediately or in a single step. You will not run into the risk of different machines working on the same piece of data, or receiving different versions of the same data.
Laravel has a unified queueing API that lets you choose from various technologies such as Redis, Amazon SQS, Beanstalkd, or even an old-fashioned relational database system.
From there, he developed Redis, which is now used as a database, cache, message broker, and queue. Redis delivers sub-millisecond response times, enabling millions of requests per second for real-time applications in industries like gaming, ad-tech, financial services, healthcare, and IoT.
Laravel supports the use of Redis, which uses caches for temporary data storage to speed up the process of performing database queries and getting feedback, which will, in turn, reduce the amount of time spent pulling up data.
I had this same problem, and it took me hours to find the solution.
https://laravel.com/docs/5.6/queues#driver-prerequisites says:
In order to use the
redis
queue driver, you should configure a Redis database connection in yourconfig/database.php
configuration file.
And then https://laravel.com/docs/5.6/redis#predis says:
In addition to the default
host
,port
,database
, andpassword
server configuration options, Predis supports additional connection parameters that may be defined for each of your Redis servers. To utilize these additional configuration options, add them to your Redis server configuration in theconfig/database.php
configuration file.
Reading the "connection parameters" page, I eventually found https://github.com/nrk/predis/wiki/Client-Options, which says that 'prefix' is a supported option.
So, you can edit your config/database.php
configuration file to have:
'redis' => [
'client' => 'predis',
'cluster' => false,
'options'=>[
'prefix' => env('REDIS_PREFIX', 'YOUR_PREFIX_HERE')
],
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
I'm not sure if you then need to restart Redis or Supervisord.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With