Просмотр исходного кода

fix(user): 解决缓存时间计算问题

- 修复了剩余秒数计算逻辑,添加随机值避免缓存雪崩
- 防止大量请求同时失效导致系统压力过大
shichen месяцев назад: 3
Родитель
Сommit
191f931a15
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      app/controller/api/user/User.php

+ 1 - 1
app/controller/api/user/User.php

@@ -3350,7 +3350,7 @@ class User extends BaseController
3350 3350
 
3351 3351
         $now = time();
3352 3352
         $todayEnd = strtotime('today 23:59:59');
3353
-        $remainingSeconds = $todayEnd - $now;
3353
+        $remainingSeconds = $todayEnd - $now + rand(1, 100);
3354 3354
         Cache::set($key, 1, $remainingSeconds);
3355 3355
 
3356 3356
         return app('json')->success($data);