[wp-hackers] getting the expiration value of a transient when OBJECT_CACHE is involved

Haluk Karamete halukkaramete at gmail.com
Thu Jun 26 18:21:26 UTC 2014

In the code segment that I pasted below ( which is straight from the core -
> option.php  ), I 'm trying to understand how I can pull the expire_time (
the unix time stamp ) for the transient I'm after.

When there is no object_cache is involved, that's a piece of ccake as
$transient_timeout )* just gets me that.


    if ( wp_using_ext_object_cache() ) {
        $value = wp_cache_get( $transient, 'transient' );
    } else {
        $transient_option = '_transient_' . $transient;
        if ( ! defined( 'WP_INSTALLING' ) ) {
            // If option is not in alloptions, it is not autoloaded and
thus has a timeout
            $alloptions = wp_load_alloptions();
            if ( !isset( $alloptions[$transient_option] ) ) {
                $transient_timeout = '_transient_timeout_' . $transient;
                if ( get_option( $transient_timeout ) < time() ) {
                    delete_option( $transient_option  );
                    delete_option( $transient_timeout );
                    $value = false;

        if ( ! isset( $value ) )
            $value = get_option( $transient_option );


But on an object cache situation, such as total_cache, that's been a uphill
battle for me.

All I got there for inspiration is this;

$value = wp_cache_get( $transient, 'transient' );

When I traced that function ( wp_cache_get() ) down to its roots,  I end up
with the following which did not produce any fruits neither.

     * Retrieves the cache contents from the cache by key and group.
     * @since 2.0.0
     * @uses $wp_object_cache Object Cache Class
     * @see WP_Object_Cache::get()
     * @param int|string $key What the contents in the cache are called
     * @param string $group Where the cache contents are grouped
     * @param bool $force Whether to force an update of the local cache
from the persistent cache (default is false)
     * @param &bool $found Whether key was found in the cache.
Disambiguates a return of false, a storable value.
     * @return bool|mixed False on failure to retrieve contents or the cache
     *        contents on success
    function wp_cache_get( $key, $group = '', $force = false, &$found =
null ) {
        global $wp_object_cache;

        return $wp_object_cache->get( $key, $group, $force, $found );

As you see, there is no talk on $expire there neither.

Then the ball is sent to $wp_object_cache->get court...  and I got lost in

Could someone shed some light where to go to get that timestamp?

My goal is to be able to report back to me when the current transient will
expire for the current page.

On my local host, I display this at the bottom of the page without sweat:

    This page's transient will expire in 0 day(s) 0 hour(s) 0 min(s) 30

But for the development server, I got nada. :(

More information about the wp-hackers mailing list