feat: implement content cache

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-09-29 19:56:30 -04:00
parent d28800a04e
commit 0250b5a847
10 changed files with 511 additions and 8 deletions
+4 -1
View File
@@ -105,6 +105,7 @@ class EntityResource extends EntityMutableAbstract {
return [
'schemaVersion' => self::CACHE_SCHEMA_VERSION,
'created' => $this->data['created'] ?? null,
'incomplete' => $this->getProperties()->getIncompleteSections(),
'properties' => $this->getProperties()->toCacheContent(),
];
}
@@ -124,7 +125,9 @@ class EntityResource extends EntityMutableAbstract {
$this->data['created'] = $content['created'];
}
$this->getProperties()->fromCacheContent($content['properties'] ?? []);
$this->getProperties()
->fromCacheContent($content['properties'] ?? [])
->setIncompleteSections(...array_map('strval', $content['incomplete'] ?? []));
return $this;
}
+24
View File
@@ -20,12 +20,20 @@ use KTXF\Mail\Object\MessagePropertiesMutableAbstract;
*/
class MessageProperties extends MessagePropertiesMutableAbstract {
/**
* Part ids of text sections that were cut off when fetched (cache only, not part of the API shape)
*
* @var list<string>
*/
private array $incompleteSections = [];
/**
* Convert IMAP data to mail message properties object.
*/
public function fromImap(Message $message): static
{
$this->data[static::PROPERTY_SIZE] = $message->size();
$this->incompleteSections = $message->truncatedSections();
if ($message->messageId() !== null) {
$this->data[static::PROPERTY_URID] = $message->messageId();
@@ -111,6 +119,22 @@ class MessageProperties extends MessagePropertiesMutableAbstract {
// ── Cache (meta store / content store) ───────────────────────────────────
/**
* Part ids of text sections that were cut off when fetched and must be completed on open.
*
* @return list<string>
*/
public function getIncompleteSections(): array
{
return $this->incompleteSections;
}
public function setIncompleteSections(string ...$partIds): static
{
$this->incompleteSections = array_values(array_unique($partIds));
return $this;
}
/**
* Serialise the fields the meta store needs for list, filter and sort.
*