Removed packet cache, it wasnt used and not needed since we can queue large packets. Renamed to for consistent variable when using Packet::process()
This commit is contained in:
@@ -13,13 +13,15 @@ use App\Classes\FTN as FTNBase;
|
||||
use App\Models\{Address,Software,System,Zone};
|
||||
|
||||
/**
|
||||
* Represents the structure of a message bundle
|
||||
* Represents a Fidonet Packet, that contains an array of messages.
|
||||
*
|
||||
* Thus this object is iterable as an array of Message::class.
|
||||
*/
|
||||
class Packet extends FTNBase implements \Iterator, \Countable
|
||||
{
|
||||
private const LOGKEY = 'PKT';
|
||||
|
||||
private const BLOCKSIZE = 1024;
|
||||
private const BLOCKSIZE = 1024;
|
||||
protected const PACKED_MSG_LEAD = "\02\00";
|
||||
|
||||
public const PACKET_TYPES = [
|
||||
@@ -35,8 +37,7 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
||||
public File $file; // Packet filename
|
||||
public Collection $messages; // Messages in the Packet
|
||||
public Collection $errors; // Messages that fail validation
|
||||
public bool $use_cache = FALSE; // Use a cache for messages.
|
||||
protected int $index; // Our array index
|
||||
protected int $index; // Our array index
|
||||
|
||||
/**
|
||||
* @param string|null $header
|
||||
@@ -172,11 +173,10 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
||||
* @param string $name
|
||||
* @param int $size
|
||||
* @param System|null $system
|
||||
* @param bool $use_cache
|
||||
* @return Packet
|
||||
* @throws InvalidPacketException
|
||||
*/
|
||||
public static function process(mixed $f,string $name,int $size,System $system=NULL,bool $use_cache=FALSE): self
|
||||
public static function process(mixed $f,string $name,int $size,System $system=NULL): self
|
||||
{
|
||||
Log::debug(sprintf('%s:+ Opening Packet [%s] with size [%d]',self::LOGKEY,$name,$size));
|
||||
|
||||
@@ -207,7 +207,6 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
||||
if (! $o)
|
||||
throw new InvalidPacketException('Cannot determine type of packet.');
|
||||
|
||||
$o->use_cache = $use_cache;
|
||||
$o->name = $name;
|
||||
|
||||
$x = fread($f,2);
|
||||
@@ -338,12 +337,12 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
||||
|
||||
public function current(): Message
|
||||
{
|
||||
return $this->use_cache ? unserialize(Cache::pull($this->key())) : $this->messages->get($this->index);
|
||||
return $this->messages->get($this->index);
|
||||
}
|
||||
|
||||
public function key(): mixed
|
||||
{
|
||||
return $this->use_cache ? $this->messages->get($this->index) : $this->index;
|
||||
return $this->index;
|
||||
}
|
||||
|
||||
public function next(): void
|
||||
@@ -358,7 +357,7 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
||||
|
||||
public function valid(): bool
|
||||
{
|
||||
return (! is_null($this->key())) && ($this->use_cache ? Cache::has($this->key()) : $this->messages->has($this->key()));
|
||||
return (! is_null($this->key())) && $this->messages->has($this->key());
|
||||
}
|
||||
|
||||
/* METHODS */
|
||||
@@ -514,15 +513,6 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->use_cache) {
|
||||
$key = urlencode($msg->msgid ?: sprintf('%s %s',$msg->fftn,Carbon::now()->timestamp));
|
||||
if (! Cache::forever($key,serialize($msg)))
|
||||
throw new \Exception(sprintf('Caching failed for key [%s]?',$key));
|
||||
|
||||
$this->messages->push($key);
|
||||
|
||||
} else {
|
||||
$this->messages->push($msg);
|
||||
}
|
||||
$this->messages->push($msg);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user