Change default internal caching to off, and added test to make sure things are cached if on. More debugging with packet name for netmails

This commit is contained in:
Deon George
2023-01-25 16:26:10 +11:00
parent 63e3397aee
commit 3dc18a3f1f
3 changed files with 13 additions and 5 deletions

View File

@@ -58,7 +58,7 @@ class Packet extends FTNBase implements \Iterator, \Countable
public Collection $messages; // Messages in the Packet
public Collection $errors; // Messages that fail validation
private string $name; // Packet name
public bool $use_cache = TRUE; // Use a cache for messages.
public bool $use_cache = FALSE; // Use a cache for messages.
private int $index; // Our array index
/**
@@ -124,7 +124,7 @@ class Packet extends FTNBase implements \Iterator, \Countable
* @throws InvalidPacketException
*/
public static function process(mixed $f,string $name,int $size,System $system=NULL,bool $use_cache=TRUE): self
public static function process(mixed $f,string $name,int $size,System $system=NULL,bool $use_cache=FALSE): self
{
Log::debug(sprintf('%s:+ Opening Packet [%s] with size [%d]',self::LOGKEY,$name,$size));
@@ -523,7 +523,9 @@ class Packet extends FTNBase implements \Iterator, \Countable
if ($this->use_cache) {
$key = urlencode($msg->msgid ?: sprintf('%s %s',$msg->fftn,Carbon::now()->timestamp));
Cache::forever($key,serialize($msg));
if (! Cache::forever($key,serialize($msg)))
throw new \Exception(sprintf('Caching failed for key [%s]?',$key));
$this->messages->push($key);
} else {