WordPress.org

Ready to get started?Download WordPress

Ideas

Transient API should allow no expiry and no autoload

  1. webaware
    Member

    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' );

    Posted: 1 year ago #
  2. Maor Chasen
    Member

    +1. Dig it.

    Posted: 1 year ago #
  3. Ipstenu (Mika Epstein)
    Administrator

    Would a no-expire defeat part of the purpose of being transient?

    Posted: 1 year ago #
  4. webaware
    Member

    @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');

    Posted: 1 year ago #
  5. webaware
    Member

    @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?

    Posted: 1 year ago #
  6. Yakup Hoca
    Member

    12345

    Sounds like a good idea!

    Posted: 1 year ago #
  7. flentini
    Member

    +1 for the autoload parameter

    Posted: 9 months ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    6 Votes
  • Status

    This idea is under consideration