Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
fengfei committed Mar 31, 2018
1 parent 066ca17 commit c28a077
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/access.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function select_server(api_info)
local request_index_cache_key = ngx.var.host .. "_request_index_" .. api_info["request_uri"]
local request_index, _ = cache:incr(request_index_cache_key, 1)
if request_index == nil then
request_index = cache:incr(request_index_cache_key, 1, 0, 60) -- 设置一段时间过期
request_index = cache:incr(request_index_cache_key, 1, 0)
end

return servers[request_index % server_count + 1]; --Lua 的 table 索引默认从 1 开始
Expand Down

0 comments on commit c28a077

Please sign in to comment.