nginx+lua信息访问量统计

2019PHP高薪工程师学习路线图....>>>

require('Memcached')
local args = ngx.req.get_uri_args()

if (ngx.var.remote_addr == '192.168.1.5')
then
        local key = args['k']
        local class = args['c']
        local key = class..':'..key

        local memcache = Memcached.Connect('127.0.0.1', 11212)
        if (memcache:add(key,1))
        then
                memcache:get(key)
        else
                memcache:incr(key);
                ngx.print(memcache:get(key))
        end
else
        ngx.exit(404)
end