Skip to content

Commit 67c9de7

Browse files
authored
Merge pull request #887 from utopia-php/fix-document-cache-purge-race
Purge document cache again after transaction commit
2 parents 06b2195 + 633b776 commit 67c9de7

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/Database/Database.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6365,6 +6365,9 @@ public function updateDocument(string $collection, string $id, Document $documen
63656365
return $document;
63666366
}
63676367

6368+
// Purge again after commit so readers cannot re-cache the pre-commit version
6369+
$this->purgeCachedDocumentInternal($collection->getId(), $id);
6370+
63686371
if (!$this->inBatchRelationshipPopulation && $this->resolveRelationships) {
63696372
$documents = $this->silent(fn () => $this->populateDocumentsRelationships([$document], $collection, $this->relationshipFetchDepth));
63706373
$document = $documents[0];
@@ -7751,6 +7754,8 @@ public function deleteDocument(string $collection, string $id): bool
77517754
});
77527755

77537756
if ($deleted) {
7757+
// Purge again after commit so readers cannot re-cache the pre-commit version
7758+
$this->purgeCachedDocumentInternal($collection->getId(), $id);
77547759
$this->trigger(self::EVENT_DOCUMENT_DELETE, $document);
77557760
}
77567761

0 commit comments

Comments
 (0)