monospice / laravel-redis-sentinel-drivers

Redis Sentinel integration for Laravel and Lumen.
MIT License
101 stars 48 forks source link

Help needed on hybrid setup - Sentinel cluster shared on Laravel & Java App #38

Open jab1000 opened 2 years ago

jab1000 commented 2 years ago

We run a 3 server Redis Sentinel cluster which is shared between a laravel app and also a java application.

Presently right now, database 0 is used for the java web application with the remaining databases being laravel. Below are the configuration settings from our laravel env file:

    CACHE_DRIVER=redis-sentinel
    SESSION_DRIVER=redis-sentinel
    REDIS_DRIVER=redis-sentinel

    QUEUE_DRIVER=redis-sentinel
    QUEUE_CONNECTION=redis-sentinel
    HORIZON_DRIVER=redis-sentinel

    REDIS_HOST=172.3.4.1,172.3.4.2,172.3.4.3
    REDIS_PORT=26379
    REDIS_SENTINEL_SERVICE=mymaster

    REDIS_CACHE_DATABASE=1
    REDIS_SESSION_DATABASE=2
    REDIS_QUEUE_DATABASE=3

We have a few new laravel jobs which we need to delete/remove a cached key set by the java application. The redis prefix in the java application is not set, but the prefix is auto-added with the default laravel configuration for redis database/cache config files.

What would be the best way for laravel to access these "java application set keys" in Redis?

We did try creating another database config setting under redis area but it throws errors in production that it isn't defined. Extra cache attribute added:

   'javaCache' => [
        'url' => env('REDIS_URL'),
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => null,
        'port' => '6379',
        'database' => '0',
        'prefix'=>'',
    ]

Do we need a hybrid setup per your readme front page -- granted after reading it a couple of times, I am not sure I understand what to change though unfortunately.

Thanks for your help & feedback!