-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24a0171
commit 65a8e19
Showing
17 changed files
with
1,372 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package.path = package.path .. ";{{{config_directory}}}/?.lua" | ||
|
||
local md5 = require "md5" | ||
|
||
if ngx ~= nil then | ||
local proxy_cache_keys_by_host = ngx.shared.proxy_cache_keys_by_host | ||
|
||
local host = ngx.var.host | ||
local request_uri = ngx.var.request_uri | ||
local scheme = ngx.var.scheme | ||
|
||
local cache_key = scheme .. "://" .. host .. request_uri | ||
local cache_key_md5 = md5.sumhexa(cache_key) | ||
|
||
-- the cache file path is in the following format: | ||
-- $x/$y/$cache_key_md5 | ||
-- where x is the last character of the cache_key_md5 | ||
-- and y are the two characters before that | ||
local cache_file_path = cache_key_md5:sub(-1) .. "/" .. cache_key_md5:sub(-3,-2) .. "/" .. cache_key_md5 | ||
local already_stored = proxy_cache_keys_by_host:get(cache_file_path) | ||
|
||
if (already_stored == nil) then | ||
ngx.log(ngx.NOTICE,host .. " " .. cache_file_path.. "adding to dictionary") | ||
proxy_cache_keys_by_host:rpush(host, cache_file_path) | ||
proxy_cache_keys_by_host:set(cache_file_path, true) | ||
else | ||
ngx.log(ngx.NOTICE,host .. " " .. cache_file_path.. "already stored" ) | ||
end | ||
end |
Oops, something went wrong.