陈德本 5 vuotta sitten
vanhempi
sitoutus
0d4c1c5ba4
1 muutettua tiedostoa jossa 11 lisäystä ja 8 poistoa
  1. 11 8
      App/Api/Controller/Msg.php

+ 11 - 8
App/Api/Controller/Msg.php

@@ -6,6 +6,7 @@ namespace Heanup\App\Api\Controller;
 
 
 use Ark\Filecache\FileCache;
 use Ark\Filecache\FileCache;
 use Heanup\App\Api\Controller;
 use Heanup\App\Api\Controller;
+use Heanup\Library\Redis;
 use PhpImap\Mailbox;
 use PhpImap\Mailbox;
 
 
 class Msg extends Controller
 class Msg extends Controller
@@ -30,19 +31,21 @@ class Msg extends Controller
         $mail_info=[];
         $mail_info=[];
         $mail_ids=array_reverse($mail_ids);
         $mail_ids=array_reverse($mail_ids);
         $i=0;
         $i=0;
-        $cache = new FileCache([
-            'root' => APP_DIR.'/cache', // Cache root
-            'ttl' => 0,                    // Time to live
-            'compress' => false,             // Compress data with gzcompress or not
-            'serialize' => 'json',          // How to serialize data: json, php, raw
-        ]);
+//        $cache = new FileCache([
+//            'root' => APP_DIR.'/cache', // Cache root
+//            'ttl' => 0,                    // Time to live
+//            'compress' => false,             // Compress data with gzcompress or not
+//            'serialize' => 'json',          // How to serialize data: json, php, raw
+//        ]);
+        $cache=Redis::instance();
         foreach ($mail_ids as $mail_id) {
         foreach ($mail_ids as $mail_id) {
 
 
             if ($i>=10){
             if ($i>=10){
 //                $mailbox->deleteMail($mail_id);
 //                $mailbox->deleteMail($mail_id);
                 break;
                 break;
             }else{
             }else{
-                $temp=$cache->get($mail_id);
+                $key="mails:".$mail_id;
+                $temp=$cache->get($key);
                 if (!$temp) {
                 if (!$temp) {
                     $detail = $mailbox->getMail($mail_id);
                     $detail = $mailbox->getMail($mail_id);
                     $txt = explode("\r\n", $detail->textPlain);
                     $txt = explode("\r\n", $detail->textPlain);
@@ -56,7 +59,7 @@ class Msg extends Controller
                         'cc' => $detail->cc,
                         'cc' => $detail->cc,
                         'bcc' => $detail->bcc,
                         'bcc' => $detail->bcc,
                     ];
                     ];
-                    $cache->set($mail_id, $temp);
+                    $cache->set($key, $temp);
                 }
                 }
                 $mail_info[]=$temp;
                 $mail_info[]=$temp;
             }
             }