SoFunction
Updated on 2025-04-08

Use nginx+lua to achieve information visit statistics


require('Memcached')
local args = .get_uri_args()
 
if (.remote_addr == '192.168.1.5')
then
        local key = args['k']
        local class = args['c']
        local key = class..':'..key
 
        local memcache = ('127.0.0.1', 11212)
        if (memcache:add(key,1))
        then
                memcache:get(key)
        else
                memcache:incr(key);
                (memcache:get(key))
        end
else
        (404)
end