RyanBayne / TwitchPress

TwitchPress is a system of plugins that combines the power of Twitch.tv with WordPress
http://twitchpress.wordpress.com
GNU General Public License v3.0
12 stars 6 forks source link

User Meta OOP and Performance #259

Closed RyanBayne closed 6 years ago

RyanBayne commented 6 years ago

Look at this scenario where get_user_meta() is used twice and close together within a procedure. The Streamlabs username is queried in the user meta table as a way to ensure that a user is ready for Streamlabs services. Then we make the same query again.

image

We need to confirm that WP will not perform a second database query, and caches the first query result. I remember reading something like this but we need to confirm it. If not then we need to build and maintain suitable objects that can be shared across all extensions in the TwitchPress system.

Note the $GLOBALS value and how it is already in use. I may simply need to make much greater use of it.

image

This task is about establishing how WP operates and if needed creating a standard approach to OOP that any developer would need to adhere to when working within my system of plugins.

RyanBayne commented 6 years ago

I have confirmed that WP does cache all get_option and get_meta queries.

The use of $GLOBALS might be phased out as the new object registry will become a preferred option.