[wp-hackers] how big objects can i cache using wp transient api?

Otto otto at ottodestruct.com
Mon Oct 3 17:18:44 UTC 2011


On Mon, Oct 3, 2011 at 6:03 AM, Phillip Lord
<phillip.lord at newcastle.ac.uk> wrote:
> I may have this wrong, but looking at the back end implementation,
> transients appears to back on directly to the options API. Now at times,
> this calls "wp_load_alloptions()"
> ...
> which in turn looks like this...
>
> function wp_load_alloptions() {
> ...
>                if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) )
>                        $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
> ...
> }
>
>
> So, it seems to me, that extensive use of the transients API with big
> things is going to come with a substantial performance problem.
>
> ...
>
> Am I barking up the wrong tree here? Have I totally misunderstood the
> implementation?
>
> Phil

Transients get autoload = 'no' when they have an expiration.

function set_transient( $transient, $value, $expiration = 0 ) {
   ...
			$autoload = 'yes';
			if ( $expiration ) {
				$autoload = 'no';
				add_option( $transient_timeout, time() + $expiration, '', 'no' );
  ...
}

-Otto


More information about the wp-hackers mailing list