Skip to content

RTC: Transients for awareness and JIT meta cache flushing#11348

Draft
peterwilsoncc wants to merge 9 commits intoWordPress:trunkfrom
peterwilsoncc:64696-using-core-apis
Draft

RTC: Transients for awareness and JIT meta cache flushing#11348
peterwilsoncc wants to merge 9 commits intoWordPress:trunkfrom
peterwilsoncc:64696-using-core-apis

Conversation

@peterwilsoncc
Copy link
Contributor

@peterwilsoncc peterwilsoncc commented Mar 25, 2026

This does a few things:

  • Moves awareness to the transients API: For sites with a persistent cache awareness will be stored in the object cache, the options table for site that don't
  • As the transients have a timeout set, they will not be autoloaded or invalidate the alloptions cache
  • Reduces awareness granularity to 10 seconds (rounded up), this changes the awareness timeout to be anywhere between 30 and 39 seconds which is close enough. It will also reduce database writes/cache invalidation
  • Introduces a filter wp_sync_awareness_timestamp_granularity to allow granularity to be modified by third party devs
  • Reverts r62099 to use the Meta APIs for syncing updates: I think this will be helpful as rooms meta data will no longer be updated following an awareness update. This will allow the cache to be used for rooms that have not had an update since the last polling update (eg, browser open while making lunch)
  • Introduces just in time cache invalidation for meta queries in WP_Query -- modifying the meta data will set a flag that the WP_Query post group will need to be invalidated next time a site makes a meta query
  • Adds tests for above

Trac ticket: https://core.trac.wordpress.org/ticket/64696

Use of AI Tools


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@peterwilsoncc peterwilsoncc changed the title Transients for awareness Transients for awareness and JIT meta cache flushing Mar 26, 2026
@peterwilsoncc peterwilsoncc force-pushed the 64696-using-core-apis branch from 8418c0e to 107a5cb Compare March 26, 2026 01:29
@peterwilsoncc peterwilsoncc force-pushed the 64696-using-core-apis branch from 2977e90 to f3467c2 Compare March 26, 2026 02:31
@peterwilsoncc peterwilsoncc changed the title Transients for awareness and JIT meta cache flushing RTC: Transients for awareness and JIT meta cache flushing Mar 26, 2026
* soon, so the transient can be maintained for longer to avoid additional
* entries in the options table.
*/
set_transient( self::AWARENESS_TRANSIENT_PREFIX . ":{$room_hash}", $awareness, HOUR_IN_SECONDS );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of tempted to just set this for a day given the patterns room is shared for all posts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant