diff --git a/src/Model/HybridSessionDataObject.php b/src/Model/HybridSessionDataObject.php index cdae2f3..d7ca269 100644 --- a/src/Model/HybridSessionDataObject.php +++ b/src/Model/HybridSessionDataObject.php @@ -20,4 +20,10 @@ class HybridSessionDataObject extends DataObject ]; private static $table_name = 'HybridSessionDataObject'; + + /** + * Ensure there is no risk of reading from an unsynced database replica so + * that session data is always up to date. + */ + private static bool $must_use_primary_db = true; } diff --git a/src/Store/DatabaseStore.php b/src/Store/DatabaseStore.php index 5322f6f..0a37404 100644 --- a/src/Store/DatabaseStore.php +++ b/src/Store/DatabaseStore.php @@ -68,7 +68,7 @@ public function read(string $session_id): string|false $this->getNow() ); - $result = DB::query($query); + $result = DB::withPrimary(fn() => DB::query($query)); if ($result && $result->numRecords()) { $data = $result->record();