lua脚本实现令牌桶
通过lua脚本实现原子操作 令牌桶实现 local ratelimit_info=redis.pcall("HMGET",KEYS[1],"last_mill_second","curr_permits","max_burst","rate","app") local last_mill_second=ratelimit_info[1] local curr_permits=tonumber(ratelimit_info[2]) local max_burst=tonumber(ratelimit_info[3]) local rate=tonumber(ratelimit_info[4]) local app=tostring(ratelimit_info[5]) if app == nil then return 0 end local local_curr_permits=max_burst; if(type(last_mill_second) ~='boolean' and last_mill_second ~=nil) then local reverse_permits=math.
Posted by KANG's BLOG Monday, October 18, 2021