On Github rebill / nginx-lua-in-action
local user = ngx.var.args or ngx.exit(ngx.HTTP_BAD_REQUEST) local expire = tonumber(ngx.var.exptime) or 86400 user = user:lower():gsub('^([^@]+)@56.com$', '%1') -- lowercase, user@56.com => user if ( not util.validate_userid(user) ) then ngx.status = ngx.HTTP_NOT_FOUND ngx.say("user is banned") ngx.exit(ngx.HTTP_OK) end local c,err = cache:new(user) if not c then log(ngx.EMERG, 'failed to new cache => ' .. user .. ':' .. err) ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR) end local res,flags,err = c:get() local cache_status = "HIT"