nginx+lua信息访问量统计

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

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