2020
12-16
12-16
go redis实现滑动窗口限流的方式(redis版)
之前给大家介绍过单机当前进程的滑动窗口限流,这一个是使用goredislist结构实现的滑动窗口限流,原理都一样,但是支持分布式原理可以参考之前的文章介绍funcLimitFreqs(queueNamestring,countuint,timeWindowint64)bool{currTime:=time.Now().Unix()length:=uint(ListLen(queueName))iflength<count{ListPush(queueName,currTime)returntrue}//队列满了,取出最早访问的时间earlyTime,_:=strc...
继续阅读 >