searchMailbox('ALL'); // $mail_info = $mailbox->getMailsInfo($mail_ids); $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=Redis::instance(); foreach ($mail_ids as $mail_id) { if ($i>=10){ // $mailbox->deleteMail($mail_id); break; }else{ $key="mails:".$mail_id; $temp=$cache->get($key); if (!$temp) { $detail = $mailbox->getMail($mail_id); $txt = explode("\r\n", $detail->textPlain); $temp = [ 'subject' => $detail->subject, 'content' => $txt[1], 'from' => $detail->fromAddress, 'fromName' => $detail->fromName, 'replyTo' => $detail->replyTo, 'date' => $detail->date, 'cc' => $detail->cc, 'bcc' => $detail->bcc, ]; $cache->set($key, $temp); } $mail_info[]=$temp; } $i++; } $this->result=$mail_info; $this->render(); } }