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

cache connection

Open olrtan opened this issue 3 years ago • 1 comments

Hi , I want to ask you: can i make the connection cache?

$client= Cache::remember('client', 100000 * 60, function () {
        return $client->connect();
    });

if yes how ? thanks you

olrtan avatar Sep 18 '22 23:09 olrtan

Hi @olrtan , that's a good question. I've never tried it. You could try something like this:

$client= Cache::remember('client', 100000 * 60, function () {
    $client = Webklex\IMAP\Facades\Client::account('default');
    $client->connect();
    return $client;
});

..but I don't know if the resource / connection itself is managed properly. I also don't know if it is a good idea in general - something has to manage the open connection - does it get dropped by the sever after a certain time? Will it reconnect by itself if required? Is the session still valid after x minutes / days?

Best regards,

Webklex avatar Sep 19 '22 01:09 Webklex