Skip to content

Commit 47dda9a

Browse files
committed
massive fixes.
1 parent d3025b9 commit 47dda9a

File tree

2 files changed

+52
-10
lines changed

2 files changed

+52
-10
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,28 @@ http {
1111
lua_package_path "/path/to/lua-ssl-nginx-module/lualib/?.lua;;";
1212
1313
lua_shared_dict my_cache 10m;
14+
lua_shared_dict locks 1m;
1415
1516
init_by_lua_block {
1617
require("ngx.ssl.session.ticket.key_rotation").init{
17-
shdict_name = "my_cache",
18+
locks_shdict_name = "locks",
19+
cache_shdict_name = "my_cache",
1820
shm_cache_positive_ttl = 24 * 3600 * 1000, -- in ms
1921
shm_cache_negative_ttl = 0, -- in ms
2022
disable_shm_cache = false, -- default false
2123
memc_key_prefix = "ticket-key/",
2224
ticket_ttl = 24 * 3600, -- in sec
2325
key_rotation_period = 3600, -- in sec
26+
27+
memc_host = "127.0.0.1",
28+
memc_port = 11211,
29+
memc_timeout = 500, -- in ms
30+
memc_conn_pool_size = 1,
31+
memc_fetch_retries = 1, -- optional, default 1
32+
memc_fetch_retry_delay = 100, -- in ms, optional, default to 100 (ms)
33+
34+
memc_conn_max_idle_time = 1 * 1000, -- in ms, for in-pool connections,
35+
-- optional, default to nil
2436
}
2537
}
2638

lualib/ngx/ssl/session/ticket/key_rotation.lua

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,37 @@ do
7171
end
7272

7373

74-
local fetch_key_from_memc
74+
local fetch_key_from_memc, locks_shdict_name
75+
local memc_host, memc_port, memc_timeout, memc_conn_pool_size
76+
local memc_fetch_retries, memc_fetch_retry_delay, memc_conn_max_idle_time
7577
do
7678
local memc_shdict = require "resty.memcached.shdict"
7779
local fetch_key_from_memc = memc_shdict.gen_memc_methods{
78-
debug_logger = dlog,
79-
warn_logger = warn,
80-
error_logger = error_log,
81-
disable_shdict = disable_shm_cache,
82-
shdict_set = meta_shdict_set,
83-
shdict_get = meta_shdict_get,
84-
}
80+
tag = "ticket_memc",
81+
82+
debug_logger = dlog,
83+
warn_logger = warn,
84+
error_logger = error_log,
85+
86+
locks_shdict_name = locks_shdict_name,
87+
88+
disable_shdict = disable_shm_cache,
89+
90+
shdict_set = meta_shdict_set,
91+
shdict_get = meta_shdict_get,
92+
93+
memc_host = memc_host,
94+
memc_port = memc_port,
95+
memc_timeout = memc_timeout,
96+
memc_conn_pool_size = memc_conn_pool_size,
97+
memc_fetch_retries = memc_fetch_retries,
98+
memc_fetch_retry_delay = memc_fetch_retry_delay,
99+
100+
memc_conn_max_idle_time = memc_conn_max_idle_time,
101+
102+
memc_store_retries = 0,
103+
memc_store_retry_delay = 0,
104+
}
85105
end
86106

87107

@@ -249,10 +269,20 @@ function _M.init(opts)
249269
time_slot = opts.key_rotation_period
250270
memc_key_prefix = opts.memc_key_prefix
251271

252-
shdict_name = opts.shdict_name
272+
shdict_name = opts.cache_shdict_name
253273
shm_cache_pos_ttl = opts.shm_cache_positive_ttl
254274
shm_cache_neg_ttl = opts.shm_cache_negative_ttl
255275
disable_shm_cache = opts.disable_shm_cache
276+
locks_shdict_name = opts.locks_shdict_name
277+
278+
memc_host = opts.memc_host
279+
memc_port = opts.memc_port
280+
memc_timeout = opts.memc_timeout
281+
memc_conn_pool_size = opts.memc_conn_pool_size
282+
memc_fetch_retries = opts.memc_fetch_retries
283+
memc_fetch_retry_delay = opts.memc_fetch_retry_delay
284+
285+
memc_conn_max_idle_time = opts.memc_conn_max_idle_time
256286

257287
local frandom = assert(io.open("/dev/urandom", "rb"))
258288
fallback_random_key = frandom:read(48)

0 commit comments

Comments
 (0)