xiaogang 4 years ago
parent
commit
e474a6360f
2 changed files with 3 additions and 4 deletions
  1. 1 3
      app/Http/Controllers/Api/HomeController.php
  2. 2 1
      app/Services/HomeService.php

+ 1 - 3
app/Http/Controllers/Api/HomeController.php

xqd
@@ -184,12 +184,10 @@ class HomeController extends Controller
             $cache_eq_id = $request->header('uniqueID','');//获取设备码
             $lock = Cache::lock(ApiEnum::PHOTO_DESTROY_LOCK.$cache_eq_id, 1);
 
-            dd(Redis::get(ApiEnum::PHOTO_DESTROY_URL.$cache_eq_id.md5($request->url)));
             if ($lock->get()) {
                 if(!$user){
                     if(!Redis::get(ApiEnum::PHOTO_DESTROY_URL.$cache_eq_id.md5($request->url))){
-                        Redis::set(ApiEnum::PHOTO_DESTROY_URL.$cache_eq_id.md5($request->url),$request->url);
-                        dd(Redis::get(ApiEnum::PHOTO_DESTROY_URL.$cache_eq_id.md5($request->url)));
+                        Redis::setex(ApiEnum::PHOTO_DESTROY_URL.$cache_eq_id.md5($request->url),86400*365,$request->url);
                     }
                 }else{
                     if(!UserPhotoDestroy::query()->where(['user_id'=>$user->id,'url'=>$request->url])->first()){

+ 2 - 1
app/Services/HomeService.php

xqd xqd
@@ -14,6 +14,7 @@ use App\Models\UserLikeModel;
 use App\Models\UserPhotoDestroy;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Redis;
 use PHPUnit\Util\Exception;
 
 class HomeService
@@ -99,7 +100,7 @@ class HomeService
             //查询是否阅后即焚
             if(count($photo)>0){
                 foreach ($photo as $k=>$v){
-                    if($v['state']==1 && Cache::has(ApiEnum::PHOTO_DESTROY_URL.request()->header('uniqueID').md5($v['url']))){
+                    if($v['state']==1 && Redis::get(ApiEnum::PHOTO_DESTROY_URL.request()->header('uniqueID').md5($v['url']))){
                         $photo[$k]['is_destroy'] = 1;
                     }
                 }