Explorar el Código

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

- 修复了剩余秒数计算逻辑,添加随机值避免缓存雪崩
- 防止大量请求同时失效导致系统压力过大
shichen hace 3 meses
padre
commit
191f931a15
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  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
         $now = time();
3351
         $now = time();
3352
         $todayEnd = strtotime('today 23:59:59');
3352
         $todayEnd = strtotime('today 23:59:59');
3353
-        $remainingSeconds = $todayEnd - $now;
3353
+        $remainingSeconds = $todayEnd - $now + rand(1, 100);
3354
         Cache::set($key, 1, $remainingSeconds);
3354
         Cache::set($key, 1, $remainingSeconds);
3355
 
3355
 
3356
         return app('json')->success($data);
3356
         return app('json')->success($data);