Przeglądaj źródła

refactor(cache): 优化物流查询缓存键名

- 将缓存键名变量名从 cacheKey 更改为 name
- 保持原有的缓存逻辑和限制规则不变
- 提高代码可读性和一致性
runphp 5 miesięcy temu
rodzic
commit
925e2087be
1 zmienionych plików z 3 dodań i 3 usunięć
  1. 3 3
      src/Entity/ExtensionWuLiuEntity.php

+ 3 - 3
src/Entity/ExtensionWuLiuEntity.php

@@ -22,9 +22,9 @@ class ExtensionWuLiuEntity extends BaseEntity
             return $entity->toArray();
         }
         // 一个人一天最多查询100次
-        $cacheKey = 'wuliu_' . date('Ymd') . '_' . $userID;
-        $times = Cache::remember($cacheKey, function () use ($cacheKey) {
-            return Cache::get($cacheKey, 0) + 1;
+        $name = 'wuliu_' . date('Ymd') . '_' . $userID;
+        $times = Cache::remember($name, function () use ($name) {
+            return Cache::get($name, 0) + 1;
         }, 86400);
         if ($times > 100) {
             throw_logic_exception('查询太过频繁,请明天再试');