From 48b76d139558c0b4f4013df59a4f8186b4cf5e9a Mon Sep 17 00:00:00 2001 From: Kload Date: Fri, 29 Nov 2013 13:22:36 +0100 Subject: [PATCH] ARM cache bugfix --- access.lua | 1 - init.lua | 13 +++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/access.lua b/access.lua index 2cd5118..77951d5 100644 --- a/access.lua +++ b/access.lua @@ -2,7 +2,6 @@ -- Load configuration -- cache = ngx.shared.cache -srvkey = cache:get("srvkey") oneweek = 60 * 60 * 24 * 7 cookies = {} local conf_file = assert(io.open(conf_path, "r"), "Configuration file is missing") diff --git a/init.lua b/init.lua index 41f67d1..2876d81 100644 --- a/init.lua +++ b/init.lua @@ -11,8 +11,17 @@ math = require "math" hige = require "hige" -- Set random key -math.randomseed(os.time()) -ngx.shared.cache:add("srvkey", math.random(1111111, 9999999)) +local file = io.open("/tmp/ngx_srvkey","r") +if file ~= nil then + srvkey = file:read("*all") + file:close() +else + local file = io.open("/tmp/ngx_srvkey","w") + math.randomseed(os.time()) + srvkey = tostring(math.random(1111111, 9999999)) + file:write(srvkey) + file:close() +end -- Shared table flashs = {}