KarelCemus / play-redis

Play framework 2 cache plugin as an adapter to redis-server
Mozilla Public License 2.0
164 stars 44 forks source link

Support RedisClientMasterSlaves #295

Closed alexmihailov closed 6 months ago

alexmihailov commented 7 months ago

In many cases, there is a need to write data to the master, and read from one of the slave nodes. The rediscala library supports such functionality using class redis.RedisClientMasterSlaves. I implemented support for RedisClientMasterSlaves by specifying the configuration source: master-slaves. Example:

play.cache.redis {
    source: master-slaves

    # username to your redis hosts (optional)
    username: some-username
    # password to your redis hosts, use if not specified for a specific node (optional)
    password: "my-password"
    # number of your redis database, use if not specified for a specific node (optional)
    database: 1 

    # master node
    master: {
        host: "localhost"
        port: 6380
        # number of your redis database on master (optional)
        database: 1
        # username on master host (optional)
        username: some-username
        # password on master host (optional)
        password: something
    }
    # slave nodes
    slaves: [
        {
            host: "localhost"
            port: 6381
            # number of your redis database on slave (optional)
            database: 1
            # username on slave host (optional)
            username: some-username
            # password on slave host (optional)
            password: something
        }
    ]
}
KarelCemus commented 6 months ago

Releasing as 4.1.0, thank you for your contribution