php-imap icon indicating copy to clipboard operation
php-imap copied to clipboard

Retrieve related messages with cache

Open starking8b opened this issue 1 year ago • 0 comments

I am using laravel in order to get messages and this is my code

$client = Client::account('default');
 $folder = $client->getFolder("Inbox");
 $message = Cache::remember('Mail_MSGN_'.$id,50000, function () use($id,$folder) {
    return  $folder->query()->getMessageByMsgn($id);
 });
 $relatedmessages=    Cache::remember('Mail_MSGN_related_'.$id,50000, function () use($message,$folder) {

  return   $message->thread($folder);
 });

if I used that code it is not working and I get an error

BAD Command Argument Error. 12

if I disabled the cache for query messages like this code

 $client = Client::account('default');
    $folder = $client->getFolder("Inbox");
    $message =   $folder->query()->getMessageByMsgn($id);
 
    $relatedmessages=    Cache::remember('Mail_MSGN_related_'.$id,50000, function () use($message,$folder) {

     return   $message->thread($folder);
    });

it is not through any error but then I am only able to access the body but not able to access the other attributes like from ,to ..etc

but when I disabled cache at all it is working fine without problem but it is so slow to get the messages

starking8b avatar Aug 16 '23 08:08 starking8b