|
|
@@ -6,6 +6,7 @@ namespace Heanup\App\Api\Controller;
|
|
|
|
|
|
use Ark\Filecache\FileCache;
|
|
|
use Heanup\App\Api\Controller;
|
|
|
+use Heanup\Library\Redis;
|
|
|
use PhpImap\Mailbox;
|
|
|
|
|
|
class Msg extends Controller
|
|
|
@@ -30,19 +31,21 @@ class Msg extends Controller
|
|
|
$mail_info=[];
|
|
|
$mail_ids=array_reverse($mail_ids);
|
|
|
$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) {
|
|
|
|
|
|
if ($i>=10){
|
|
|
// $mailbox->deleteMail($mail_id);
|
|
|
break;
|
|
|
}else{
|
|
|
- $temp=$cache->get($mail_id);
|
|
|
+ $key="mails:".$mail_id;
|
|
|
+ $temp=$cache->get($key);
|
|
|
if (!$temp) {
|
|
|
$detail = $mailbox->getMail($mail_id);
|
|
|
$txt = explode("\r\n", $detail->textPlain);
|
|
|
@@ -56,7 +59,7 @@ class Msg extends Controller
|
|
|
'cc' => $detail->cc,
|
|
|
'bcc' => $detail->bcc,
|
|
|
];
|
|
|
- $cache->set($mail_id, $temp);
|
|
|
+ $cache->set($key, $temp);
|
|
|
}
|
|
|
$mail_info[]=$temp;
|
|
|
}
|