Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I have two redis one master and one from use , how to Read and write separation use lua-resty-redis-connector #29

Open
sixtool opened this issue Mar 28, 2019 · 1 comment

Comments

@sixtool
Copy link

sixtool commented Mar 28, 2019

local rc = require("resty.redis.connector").new({
    connect_timeout = 100,
    keepalive_poolsize = 100
})
local hosts = {
    {host = "127.0.0.1", db = 7, role="master",port = 7379}, --master 
    {host = "127.0.0.1", db = 7, role="slave",port = 18379} --slave  it's not work 
}

local redis, err, previous_errors = rc:try_host(hosts)
redis:set("dog4","1")
ngx.say(cjson.encode(previous_errors)),      why previouse_errors is nil ???

I have two redis one master and one from use , how to Read and write separation use lua-resty-redis-connector

@romitmisra1
Copy link

You can tweak the interface to return the role, when reading from the Sentinels. This way the table includes, the hostip, port and as well as the role.
The role can be exposed to the calling API, or a API with exclusive role based responsibility can be constructed around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants