mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-05 07:58:35 +01:00
Options, Meta APIs: Prime transient options prior to use.
Reduce the number of queries getting and setting transients on sites without a persistent cache. Transients are stored in two options: one each for the transient value and timeout. Priming the cache reduces the database queries for getting a transient from two to one. Props peterwilsoncc, swissspidy. Fixes #61193. Built from https://develop.svn.wordpress.org/trunk@58134 git-svn-id: http://core.svn.wordpress.org/trunk@57599 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
77073cce6b
commit
048c5ba580
@ -1330,7 +1330,8 @@ function get_transient( $transient ) {
|
|||||||
|
|
||||||
if ( ! isset( $alloptions[ $transient_option ] ) ) {
|
if ( ! isset( $alloptions[ $transient_option ] ) ) {
|
||||||
$transient_timeout = '_transient_timeout_' . $transient;
|
$transient_timeout = '_transient_timeout_' . $transient;
|
||||||
$timeout = get_option( $transient_timeout );
|
wp_prime_option_caches( array( $transient_option, $transient_timeout ) );
|
||||||
|
$timeout = get_option( $transient_timeout );
|
||||||
if ( false !== $timeout && $timeout < time() ) {
|
if ( false !== $timeout && $timeout < time() ) {
|
||||||
delete_option( $transient_option );
|
delete_option( $transient_option );
|
||||||
delete_option( $transient_timeout );
|
delete_option( $transient_timeout );
|
||||||
@ -1410,6 +1411,7 @@ function set_transient( $transient, $value, $expiration = 0 ) {
|
|||||||
} else {
|
} else {
|
||||||
$transient_timeout = '_transient_timeout_' . $transient;
|
$transient_timeout = '_transient_timeout_' . $transient;
|
||||||
$transient_option = '_transient_' . $transient;
|
$transient_option = '_transient_' . $transient;
|
||||||
|
wp_prime_option_caches( array( $transient_option, $transient_timeout ) );
|
||||||
|
|
||||||
if ( false === get_option( $transient_option ) ) {
|
if ( false === get_option( $transient_option ) ) {
|
||||||
$autoload = 'on';
|
$autoload = 'on';
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.6-alpha-58133';
|
$wp_version = '6.6-alpha-58134';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user