正在显示
1 个修改的文件
包含
7 行增加
和
5 行删除
| @@ -10,6 +10,7 @@ use App\Models\User\User; | @@ -10,6 +10,7 @@ use App\Models\User\User; | ||
| 10 | use App\Models\Visit\SyncSubmitTask; | 10 | use App\Models\Visit\SyncSubmitTask; |
| 11 | use App\Services\CosService; | 11 | use App\Services\CosService; |
| 12 | use Illuminate\Http\Request; | 12 | use Illuminate\Http\Request; |
| 13 | +use Illuminate\Support\Facades\Redis; | ||
| 13 | 14 | ||
| 14 | class SelfSiteController extends BaseController | 15 | class SelfSiteController extends BaseController |
| 15 | { | 16 | { |
| @@ -47,13 +48,14 @@ class SelfSiteController extends BaseController | @@ -47,13 +48,14 @@ class SelfSiteController extends BaseController | ||
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | //判断token是否有效 | 50 | //判断token是否有效 |
| 50 | -// $cache_key = 'self_site_api_' . $pid . '_' . $token; | ||
| 51 | -// $project_info = redis_get($cache_key); | ||
| 52 | -// if ($project_info === null) { | 51 | + $cache_key = 'self_site_api_' . $pid . '_' . $token; |
| 52 | + $project_info = Redis::get($cache_key); | ||
| 53 | + if ($project_info === null) { | ||
| 53 | $project_model = new Project(); | 54 | $project_model = new Project(); |
| 54 | $project_info = $project_model->read(['id' => $pid, 'site_token' => $token]); | 55 | $project_info = $project_model->read(['id' => $pid, 'site_token' => $token]); |
| 55 | -// redis_set($cache_key, json_encode($project_info)); | ||
| 56 | -// } | 56 | + Redis::set($cache_key, json_encode($project_info)); |
| 57 | + Redis::expire($cache_key, 3600); | ||
| 58 | + } | ||
| 57 | 59 | ||
| 58 | if (!$project_info) { | 60 | if (!$project_info) { |
| 59 | return $this->error('token无效', 401); | 61 | return $this->error('token无效', 401); |
-
请 注册 或 登录 后发表评论