QNimate

  • CoursesVideos
  • WP PremiumPlugins
  • DemosLab
  • Home
  • QIdea
  • QTrack
Home Carbon Ads wp_load_alloptions() Function

wp_load_alloptions() Function

WordPress wp_load_alloptions() function returns an associative array. This associative array contains WordPress options and transients whose autoload property is set to true. By default all options and transients have autoload property set to true. WordPress does let you set a option’s autoload property to false.

The purpose of this function is the load all the keys-values in object cache which are used in almost all page requests.

Internally before wp_load_alloptions() function tries to query mysql database it checks if an alloptions key is present in WordPress object cache. If its present there then this function just returns the value(an array) associated with the key. If alloptions key is not found in object cache then this function fetches the options and transients(with autoload property set to true) from MySQL and then creates a array from the returned rows. Before returning the array it sets the alloptions key in object cache with the created array as value. So that when next time its called it doesn’t have to fetch all key-value pairs from SQL which is an very expensive task.

This function is used by WordPress Options API and Transients API. Before they search for keys, add keys or update keys in object cache and/or MySQL they use the array returned by this function. While updating, deleting and adding keys WordPress options and transients API update the alloptions key too to keep it updated. Remember that its only updated if the options or transients have autoload property set to true.

Note: If wp_load_alloptions() doesn’t find keys in options table with autoload property set to true then it retrieves all the key-value pairs.

Mar 3, 2015Narayan Prusty
WordPress $notoptions ArrayHow Does WordPress Cache Data?
Comments: 0

    Leave a Reply Cancel reply

    To create code blocks or other preformatted text, indent by four spaces:

        This will be displayed in a monospaced font. The first four
        spaces will be stripped off, but all other whitespace
        will be preserved.
        
        Markdown is turned off in code blocks:
         [This is not a link](http://example.com)
    

    To create not a block, but an inline code span, use backticks:

    Here is some inline `code`.

    For more help see http://daringfireball.net/projects/markdown/syntax

    Narayan Prusty

    I am a software engineer specialising in Blockchain, DevOps and Go/JavaScript. This is my personal blog where I write about things that I learn and feel interesting to share.

    8 years ago 1 Comment WordPress
    Share this
    0
    GooglePlus
    0
    Facebook
    0
    Twitter
    0
    Linkedin
    Related Articles
    • WordPress $notoptions Array
    • WordPress MySQL Database Table Structures
    • Creating WordPress Tables and Storing Data
    • “foreach” vs “for of” vs “for in” in JavaScript
    • File Upload using WordPress Settings API
    Our Sponsor
    My Books

    2014 - 2015 © QNimate
    All tutorials MIT license