|
|
|
@ -13,6 +13,7 @@ func checkKeyAndTimeCount(key string) (int, error) {
|
|
|
|
var timeOut = 60 * time.Second
|
|
|
|
var timeOut = 60 * time.Second
|
|
|
|
var timeCount = 30
|
|
|
|
var timeCount = 30
|
|
|
|
userInfoStr, err := Redis.Get(context.Background(), "user:"+key).Result()
|
|
|
|
userInfoStr, err := Redis.Get(context.Background(), "user:"+key).Result()
|
|
|
|
|
|
|
|
log.Printf("用户信息 %s", userInfoStr)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
//用户不存在
|
|
|
|
//用户不存在
|
|
|
|
return 401, errors.New("40003")
|
|
|
|
return 401, errors.New("40003")
|
|
|
|
@ -24,6 +25,7 @@ func checkKeyAndTimeCount(key string) (int, error) {
|
|
|
|
return 401, errors.New("40004")
|
|
|
|
return 401, errors.New("40004")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
count, err := Redis.Incr(context.Background(), "user:count:"+key).Result()
|
|
|
|
count, err := Redis.Incr(context.Background(), "user:count:"+key).Result()
|
|
|
|
|
|
|
|
log.Printf("用户请求次数 %d", count)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("系统计数器设置异常 %s", err.Error())
|
|
|
|
log.Printf("系统计数器设置异常 %s", err.Error())
|
|
|
|
return 500, errors.New("系统计数器设置异常")
|
|
|
|
return 500, errors.New("系统计数器设置异常")
|
|
|
|
|