Skip to content

Commit d196de8

Browse files
committed
Add phpdoc explaining the use of transients for awareness
1 parent 4ff1c07 commit d196de8

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/wp-includes/collaboration/class-wp-sync-post-meta-storage.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ public function add_update( string $room, $update ): bool {
9393
/**
9494
* Gets awareness state for a given room.
9595
*
96+
* Awareness data is stored in a transient with a short TTL. Transients may
97+
* be evicted at any time (cache flush, deploy, expiration), in which case
98+
* this method returns an empty array and clients briefly appear offline
99+
* until the next poll repopulates state (typically under one second).
100+
*
96101
* @since 7.0.0
97102
*
98103
* @param string $room Room identifier.
@@ -111,6 +116,11 @@ public function get_awareness_state( string $room ): array {
111116
/**
112117
* Sets awareness state for a given room.
113118
*
119+
* Uses a transient rather than post meta to avoid database write churn,
120+
* since awareness data (cursor positions, selections) is ephemeral and
121+
* repopulated on every client poll. A cache eviction only causes a brief
122+
* flicker rather than data loss.
123+
*
114124
* @since 7.0.0
115125
*
116126
* @param string $room Room identifier.

0 commit comments

Comments
 (0)