diff --git a/src/Database/Database.php b/src/Database/Database.php index f9fad6808..1a3a2adf0 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -6365,6 +6365,9 @@ public function updateDocument(string $collection, string $id, Document $documen return $document; } + // Purge again after commit so readers cannot re-cache the pre-commit version + $this->purgeCachedDocumentInternal($collection->getId(), $id); + if (!$this->inBatchRelationshipPopulation && $this->resolveRelationships) { $documents = $this->silent(fn () => $this->populateDocumentsRelationships([$document], $collection, $this->relationshipFetchDepth)); $document = $documents[0]; @@ -7751,6 +7754,8 @@ public function deleteDocument(string $collection, string $id): bool }); if ($deleted) { + // Purge again after commit so readers cannot re-cache the pre-commit version + $this->purgeCachedDocumentInternal($collection->getId(), $id); $this->trigger(self::EVENT_DOCUMENT_DELETE, $document); }