Kaynağa Gözat

cache -> RedisClusters

visuddhinanda 2 yıl önce
ebeveyn
işleme
ff64af847a

+ 2 - 1
app/Console/Commands/ExportChapterIndex.php

@@ -8,6 +8,7 @@ use App\Models\ProgressChapter;
 use App\Models\Channel;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Log;
+use App\Tools\RedisClusters;
 
 class ExportChapterIndex extends Command
 {
@@ -63,7 +64,7 @@ class ExportChapterIndex extends Command
 
         $publicChannels = Channel::where('status',30)->select('uid')->get();
         $rows = ProgressChapter::whereIn('channel_id',$publicChannels)->count();
-        Cache::put("/export/chapter/count",$rows,3600*10);
+        RedisClusters::put("/export/chapter/count",$rows,3600*10);
         $bar = $this->output->createProgressBar($rows);
         foreach (ProgressChapter::whereIn('channel_id',$publicChannels)
                                 ->select(['uid','book','para',

+ 8 - 6
app/Console/Commands/ExportOffline.php

@@ -6,6 +6,8 @@ use Illuminate\Console\Command;
 use Illuminate\Support\Facades\Storage;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Log;
+use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Redis;
 
 class ExportOffline extends Command
 {
@@ -66,7 +68,7 @@ class ExportOffline extends Command
         //导出channel
         $this->info('channel');
         $this->call('export:channel');
-        
+
         //tag
         $this->info('tag');
         $this->call('export:tag');
@@ -85,7 +87,7 @@ class ExportOffline extends Command
         $this->call('export:sentence',['--type'=>'original']);
 
         $this->info('zip');
-        
+
         $exportPath = 'app/public/export/offline';
         $exportFile = 'wikipali-offline-'.date("Y-m-d").'.db3';
         Log::debug('zip file {filename} {format}',
@@ -109,7 +111,6 @@ class ExportOffline extends Command
         $zipFullFileName = storage_path($exportPath.'/'.$zipFile);
 
         shell_exec("cd ".storage_path($exportPath));
-        shell_exec("chmod 600 {$exportFullFileName}");
         if($this->argument('format')==='7z'){
             $command = "7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on {$zipFullFileName} {$exportFullFileName}";
         }else if($this->argument('format')==='lzma'){
@@ -123,13 +124,14 @@ class ExportOffline extends Command
         $info = array();
         $info[] = ['filename'=>$zipFile,
                    'create_at'=>date("Y-m-d H:i:s"),
-                   'chapter'=>Cache::get("/export/chapter/count"),
+                   'chapter'=>RedisClusters::get("/export/chapter/count"),
                    'filesize'=>filesize($zipFullFileName),
                    'min_app_ver'=>'1.3',
                     ];
-        Cache::put('/offline/index',$info);
+        RedisClusters::put('/offline/index',$info);
         unlink($exportStop);
-        Log::debug('zip file {filename} in {format} finished',
+
+        Log::debug('zip file {filename} in {format} saved.',
                     [
                         'filename'=>$exportFile,
                         'format'=>$this->argument('format')

+ 8 - 5
app/Http/Controllers/OfflineIndexController.php

@@ -4,6 +4,9 @@ namespace App\Http\Controllers;
 
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Cache;
+use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Redis;
+use Illuminate\Support\Facades\Log;
 
 class OfflineIndexController extends Controller
 {
@@ -15,8 +18,8 @@ class OfflineIndexController extends Controller
     public function index()
     {
         //
-        if(Cache::has('/offline/index')){
-            return Cache::get('/offline/index');
+        if(RedisClusters::has('/offline/index')){
+            return RedisClusters::get('/offline/index');
         }else{
             return [];
         }
@@ -36,12 +39,12 @@ class OfflineIndexController extends Controller
     /**
      * Display the specified resource.
      *
-     * @param  int  $id
+     * @param  string  $filename
      * @return \Illuminate\Http\Response
      */
-    public function show($id)
+    public function show($filename)
     {
-        //
+
     }
 
     /**