Transient API should allow no expiry and no autoload
Transients are stored in the wp_options table. When an expiry time is given, they are added with autoload='no'; when no expiry time is given, they are added with autoload='yes'.
NB: this has memory implications! Anything added to transients with no expiry time will be autoloaded on every page.
It would be nice to be able to set no expiry time, and no autoload, e.g.
set_transient( $transient, $value, $expiration, $autoload = 'no' );
Would a no-expire defeat part of the purpose of being transient?
@Ipstenu: Maybe, and I'm not using no-expire myself (other than to force autoload!), but it's there in the API now and seems to be being utilised. In fact, it's the default (i.e. if you don't specify expiration, it defaults to never expires -- and autoload!)
More interesting for me, actually, would be to specify an expiration and specify autoload='yes', e.g. for complex menu-building code where the cached value would be used on every page. e.g.
set_transient('my_complex_stuff', $complex_stuff, 31536000, 'yes');
@AndrewBe: Better would be to recognise that expiry time and autoload are different attributes, and not try to treat them as the same thing as currently happens. If anything, autoload should have a default of "no" unless specified, regardless of what the expiry is set at, because of the potential memory impacts of having lots of transients (caching) of who knows what size?
+1 for the autoload parameter
RSS feed for this topic
You must log in to post.