lua-resty-redis
lua-resty-redis copied to clipboard
Connect to database non-zero
It seems to me (unless I'm missing something) that lua-resty-redis only allows you to connect to database 0 of redis. You cannot specify another number.
ie this uri connects to database 7
redis://[email protected]:6379/7
@CBarraford Just use the select() method to choose which "database" to use. See the original redis documentation for the corresponding select command for more details:
http://redis.io/commands/SELECT
Thanks. But I was hoping for a way to connect to a specific db. Not connect to db 0 and switch to db 1 everytime I connect.
— Sent from Mailbox
On Sat, Nov 15, 2014 at 2:03 PM, Yichun Zhang [email protected] wrote:
@CBarraford Just use the
select()method to choose which "database" to use. See the original redis documentation for the correspondingselectcommand for more details:http://redis.io/commands/SELECT
Reply to this email directly or view it on GitHub: https://github.com/openresty/lua-resty-redis/issues/53#issuecomment-63183866
@CBarraford You can check if the connection comes from the connection pool by means of the get_reused_times method. You only need to run the select command if it is a newly established connection.
BTW, if you have connections to different databases (but to the same redis server), then you also need separate connection pools for different databases (by specifying the "pool" option of the connect method).
Thanks.
— Sent from Mailbox
On Mon, Nov 17, 2014 at 2:48 PM, Yichun Zhang [email protected] wrote:
@CBarraford You can check if the connection comes from the connection pool by means of the
get_reused_timesmethod. You only need to run theselectcommand if it is a newly established connection.BTW, if you have connections to different databases (but to the same redis server), then you also need separate connection pools for different databases (by specifying the "pool" option of the
connectmethod).Reply to this email directly or view it on GitHub: https://github.com/openresty/lua-resty-redis/issues/53#issuecomment-63363972
I tried red:select(4) but it still saved data in db0.