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

Unable to select a database while connecting. #31

Closed
nmolenaar opened this issue Nov 10, 2015 · 5 comments
Closed

Unable to select a database while connecting. #31

nmolenaar opened this issue Nov 10, 2015 · 5 comments

Comments

@nmolenaar
Copy link

All though the usage of databases in Redis seems some what useless. its a really handy feature when hosting multiple websites on the same server to avoid key collision.

Could we add this feature or put it into the documentation if it already exists?

@maurorappa
Copy link

you can simply run in the same Lua block:

redis2_query select 8;
redis2_query get foo;

This works because the queries are pipelined before using redis2_pass

@nmolenaar
Copy link
Author

Oké, does this mean i'll also get twice the raw tcp information back?

@agentzh
Copy link
Member

agentzh commented Nov 11, 2015

@NicholasMolenaar Yes. A more flexible and efficient approach is to use ngx_lua with the lua-resty-redis library instead. See

https://github.com/openresty/lua-resty-redis

@maurorappa
Copy link

Sorry guys, I don't undestand, I did a tcpodump for the redis_queries above:

09:27:19.310969 IP localhost.46289 > localhost.distinct: Flags [P.], seq 1:47, ack 1, win 512, options [nop,nop,TS val 62266277 ecr 62266277], length 46
0x0000: 4500 0062 2d3f 4000 4006 0f55 7f00 0001 E..b-?@.@..U....
0x0010: 7f00 0001 b4d1 270f d273 3699 cb96 9df7 ......'..s6.....
0x0020: 8018 0200 fe56 0000 0101 080a 03b6 1ba5 .....V..........
0x0030: 03b6 1ba5 2a32 0d0a 2436 0d0a 7365 6c65 ...._2..$6..sele
0x0040: 6374 0d0a 2431 0d0a 380d 0a2a 320d 0a24 ct..$1..8.._2..$
0x0050: 330d 0a67 6574 0d0a 2434 0d0a 696e 666f 3..get..$4..info
0x0060: 0d0a

I see both redis command batched in one packet and only once.
Where's the doubling ?

@agentzh
Copy link
Member

agentzh commented Mar 11, 2016

@maurorappa Redis supports command pipelining, which is much more efficient. See

http://redis.io/topics/pipelining

@agentzh agentzh closed this as completed Mar 11, 2016
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

3 participants