9、 限流的sql
select date_sub(now(), interval 3 hour); -- 向前退3个小时
-- 大于指定时间的记录
select * from log l where l.log_method='redisIncr' and DATE_FORMAT(l.log_time, "%Y-%m-%d")>='2021-12-30' limit 1;
-- 查询指定天的限流记录
select * from log l where l.log_method='redisIncr' and DATE_FORMAT(l.log_time, "%Y-%m-%d")='2021-12-30' limit 1;
-- 查询大于指定的时间的记录
select * from log l where l.log_method='redisIncr' and l.log_time > date_sub(now(), interval 80 hour);
-- 限流次数场景排序
select o.prt_no '阈值',
SUM(o.log_data) date_sum,
o.prt,
o.log_msg,
o.log_time
from (select distinct l.log_time,l.prt_no,l.log_data,l.prt,l.log_msg from log l where l.log_method='redisIncr' and log_time > date_sub(now(), interval 72 hour)) o
group by o.prt
order by date_sum desc;
-- 查询某个场景限流次数排序
select o.prt_no,
o.log_data ,
o.prt,
o.log_msg
from (select distinct l.log_time,l.prt_no,l.log_data,l.prt,l.log_msg from log l where l.log_method='redisIncr' and DATE_FORMAT(l.log_time, "%Y-%m-%d")>='2021-12-30') o
where o.prt='bind'
group by o.prt
order by o.log_data desc;
{
"2021-12-30 14:18:42":1,
"2021-12-30 14:18:18":1,
"2021-12-30 14:18:04":19,
"2021-12-30 14:18:28":1,
"2021-12-30 14:18:09":1,
"2021-12-30 14:18:35":1,
"2021-12-30 14:18:37":1,
"2021-12-30 14:18:38":1,
"2021-12-30 14:18:08":27,
"2021-12-30 14:18:00":2,
"2021-12-30 14:18:22":3,
"2021-12-30 14:18:43":1,
"2021-12-30 14:18:06":33,
"2021-12-30 14:18:45":1,
"2021-12-30 14:18:10":3,
"2021-12-30 14:18:52":1,
"2021-12-30 14:18:02":4,
"2021-12-30 14:18:24":1,
"2021-12-30 14:18:07":7,
"2021-12-30 14:18:25":1,
"2021-12-30 14:18:59":1,
"2021-12-30 14:18:01":4
}