Skip to content

Fix endless moved redirections, connection leak and others #100

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 56 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,33 @@ While building the client, thanks for https://github.com/cuiweixie/lua-resty-red
2. nginx.conf add config:

lua_shared_dict redis_cluster_slot_locks 100k;
lua_shared_dict redis_cluster_slots_info 100k;

3. or install by luarock, link: https://luarocks.org/modules/steve0511/resty-redis-cluster
4. or install by luarock, link: https://luarocks.org/modules/steve0511/resty-redis-cluster

### Sample usage

1. Use normal commands:

```lua
local config = {
dict_name = "test_locks", --shared dictionary name for locks, if default value is not used
refresh_lock_key = "refresh_lock", --shared dictionary name prefix for lock of each worker, if default value is not used
name = "testCluster", --rediscluster name
serv_list = { --redis cluster node list(host and port),
dict_name = "test_locks", --shared dictionary name for locks, if default value is not used
refresh_lock_key = "refresh_lock", --shared dictionary name prefix for lock of each worker, if default value is not used
slots_info_dict_name = "test_slots_info", --shared dictionary name for slots_info
name = "testCluster", --rediscluster name
serv_list = { --redis cluster node list (host and port)
{ ip = "127.0.0.1", port = 7001 },
{ ip = "127.0.0.1", port = 7002 },
{ ip = "127.0.0.1", port = 7003 },
{ ip = "127.0.0.1", port = 7004 },
{ ip = "127.0.0.1", port = 7005 },
{ ip = "127.0.0.1", port = 7006 }
},
keepalive_timeout = 60000, --redis connection pool idle timeout
keepalive_cons = 1000, --redis connection pool size
connect_timeout = 1000, --timeout while connecting
max_redirection = 5, --maximum retry attempts for redirection
max_connection_attempts = 1 --maximum retry attempts for connection
keepalive_timeout = 60000, --redis connection pool idle timeout
keepalive_cons = 1000, --redis connection pool size
connect_timeout = 1000, --timeout while connecting
max_redirection = 5, --maximum retry attempts for redirection
max_connection_attempts = 1 --maximum retry attempts for connection
}

local redis_cluster = require "rediscluster"
Expand All @@ -93,25 +95,26 @@ end

```lua
local config = {
dict_name = "test_locks", --shared dictionary name for locks, if default value is not used
refresh_lock_key = "refresh_lock", --shared dictionary name prefix for lock of each worker, if default value is not used
name = "testCluster", --rediscluster name
serv_list = { --redis cluster node list(host and port),
dict_name = "test_locks", --shared dictionary name for locks, if default value is not used
refresh_lock_key = "refresh_lock", --shared dictionary name prefix for lock of each worker, if default value is not used
name = "testCluster", --rediscluster name
slots_info_dict_name = "test_slots_info", --shared dictionary name for slots_info
serv_list = { --redis cluster node list (host and port)
{ ip = "127.0.0.1", port = 7001 },
{ ip = "127.0.0.1", port = 7002 },
{ ip = "127.0.0.1", port = 7003 },
{ ip = "127.0.0.1", port = 7004 },
{ ip = "127.0.0.1", port = 7005 },
{ ip = "127.0.0.1", port = 7006 }
},
keepalive_timeout = 60000, --redis connection pool idle timeout
keepalive_cons = 1000, --redis connection pool size
connect_timeout = 1000, --timeout while connecting
read_timeout = 1000, --timeout while reading
send_timeout = 1000, --timeout while sending
max_redirection = 5, --maximum retry attempts for redirection,
max_connection_attempts = 1, --maximum retry attempts for connection
auth = "pass" --set password while setting auth
keepalive_timeout = 60000, --redis connection pool idle timeout
keepalive_cons = 1000, --redis connection pool size
connect_timeout = 1000, --timeout while connecting
read_timeout = 1000, --timeout while reading
send_timeout = 1000, --timeout while sending
max_redirection = 5, --maximum retry attempts for redirection
max_connection_attempts = 1, --maximum retry attempts for connection
auth = "pass" --set password while setting auth
}

local redis_cluster = require "rediscluster"
Expand All @@ -131,8 +134,9 @@ end
local cjson = require "cjson"

local config = {
dict_name = "test_locks", --shared dictionary name for locks, if default value is not used
refresh_lock_key = "refresh_lock", --shared dictionary name prefix for lock of each worker, if default value is not used
dict_name = "test_locks", --shared dictionary name for locks, if default value is not used
refresh_lock_key = "refresh_lock", --shared dictionary name prefix for lock of each worker, if default value is not used
slots_info_dict_name = "test_slots_info", --shared dictionary name for slots_info
name = "testCluster",
serv_list = {
{ ip = "127.0.0.1", port = 7001 },
Expand Down Expand Up @@ -181,8 +185,9 @@ end
local cjson = require "cjson"

local config = {
dict_name = "test_locks", --shared dictionary name for locks, if default value is not used
refresh_lock_key = "refresh_lock", --shared dictionary name prefix for lock of each worker, if default value is not used
dict_name = "test_locks", --shared dictionary name for locks, if default value is not used
refresh_lock_key = "refresh_lock", --shared dictionary name prefix for lock of each worker, if default value is not used
slots_info_dict_name = "test_slots_info", --shared dictionary name for slots_info
name = "testCluster",
enable_slave_read = true,
serv_list = {
Expand Down Expand Up @@ -218,8 +223,9 @@ end
local cjson = require "cjson"

local config = {
dict_name = "test_locks", --shared dictionary name for locks, if default value is not used
refresh_lock_key = "refresh_lock", --shared dictionary name prefix for lock of each worker, if default value is not used
dict_name = "test_locks", --shared dictionary name for locks, if default value is not used
refresh_lock_key = "refresh_lock", --shared dictionary name prefix for lock of each worker, if default value is not used
slots_info_dict_name = "test_slots_info", --shared dictionary name for slots_info
name = "testCluster",
enable_slave_read = true,
serv_list = {
Expand Down Expand Up @@ -261,24 +267,25 @@ end

```lua
local config = {
dict_name = "test_locks", --shared dictionary name for locks, if default value is not used
refresh_lock_key = "refresh_lock", --shared dictionary name prefix for lock of each worker, if default value is not used
name = "testCluster", --rediscluster name
serv_list = { --redis cluster node list(host and port),
dict_name = "test_locks", --shared dictionary name for locks, if default value is not used
refresh_lock_key = "refresh_lock", --shared dictionary name prefix for lock of each worker, if default value is not used
slots_info_dict_name = "test_slots_info", --shared dictionary name for slots_info
name = "testCluster", --rediscluster name
serv_list = { --redis cluster node list (host and port)
{ ip = "127.0.0.1", port = 7001 },
{ ip = "127.0.0.1", port = 7002 },
{ ip = "127.0.0.1", port = 7003 },
{ ip = "127.0.0.1", port = 7004 },
{ ip = "127.0.0.1", port = 7005 },
{ ip = "127.0.0.1", port = 7006 }
},
keepalive_timeout = 60000, --redis connection pool idle timeout
keepalive_cons = 1000, --redis connection pool size
connect_timeout = 1000, --timeout while connecting
read_timeout = 1000, --timeout while reading
send_timeout = 1000, --timeout while sending
max_redirection = 5, --maximum retry attempts for redirection
max_connection_attempts = 1 --maximum retry attempts for connection
keepalive_timeout = 60000, --redis connection pool idle timeout
keepalive_cons = 1000, --redis connection pool size
connect_timeout = 1000, --timeout while connecting
read_timeout = 1000, --timeout while reading
send_timeout = 1000, --timeout while sending
max_redirection = 5, --maximum retry attempts for redirection
max_connection_attempts = 1 --maximum retry attempts for connection
}

local redis_cluster = require "rediscluster"
Expand All @@ -298,22 +305,23 @@ end

```lua
local config = {
dict_name = "test_locks", --shared dictionary name for locks, if default value is not used
refresh_lock_key = "refresh_lock", --shared dictionary name prefix for lock of each worker, if default value is not used
name = "testCluster", --rediscluster name
serv_list = { --redis cluster node list(host and port),
dict_name = "test_locks", --shared dictionary name for locks, if default value is not used
refresh_lock_key = "refresh_lock", --shared dictionary name prefix for lock of each worker, if default value is not used
slots_info_dict_name = "test_slots_info", --shared dictionary name for slots_info
name = "testCluster", --rediscluster name
serv_list = { --redis cluster node list (host and port)
{ ip = "127.0.0.1", port = 7001 },
{ ip = "127.0.0.1", port = 7002 },
{ ip = "127.0.0.1", port = 7003 },
{ ip = "127.0.0.1", port = 7004 },
{ ip = "127.0.0.1", port = 7005 },
{ ip = "127.0.0.1", port = 7006 }
},
keepalive_timeout = 60000, --redis connection pool idle timeout
keepalive_cons = 1000, --redis connection pool size
connect_timeout = 1000, --timeout while connecting
max_redirection = 5, --maximum retry attempts for redirection
max_connection_attempts = 1, --maximum retry attempts for connection
keepalive_timeout = 60000, --redis connection pool idle timeout
keepalive_cons = 1000, --redis connection pool size
connect_timeout = 1000, --timeout while connecting
max_redirection = 5, --maximum retry attempts for redirection
max_connection_attempts = 1, --maximum retry attempts for connection
connect_opts = {
ssl = true,
ssl_verify = true,
Expand Down
Loading