Make WordPress Core


Ignore:
Timestamp:
05/11/2024 11:51:55 PM (8 months ago)
Author:
peterwilsoncc
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/option.php

    r58105 r58134  
    13311331            if ( ! isset( $alloptions[ $transient_option ] ) ) {
    13321332                $transient_timeout = '_transient_timeout_' . $transient;
    1333                 $timeout           = get_option( $transient_timeout );
     1333                wp_prime_option_caches( array( $transient_option, $transient_timeout ) );
     1334                $timeout = get_option( $transient_timeout );
    13341335                if ( false !== $timeout && $timeout < time() ) {
    13351336                    delete_option( $transient_option );
     
    14111412        $transient_timeout = '_transient_timeout_' . $transient;
    14121413        $transient_option  = '_transient_' . $transient;
     1414        wp_prime_option_caches( array( $transient_option, $transient_timeout ) );
    14131415
    14141416        if ( false === get_option( $transient_option ) ) {
Note: See TracChangeset for help on using the changeset viewer.