[wp-trac] [WordPress Trac] #16287: get_option() - store retrieved option in a global array?
WordPress Trac
wp-trac at lists.automattic.com
Tue Jan 18 16:15:09 UTC 2011
#16287: get_option() - store retrieved option in a global array?
----------------------------------+----------------------
Reporter: digitalnature | Owner:
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: Database | Version: 3.1
Severity: normal | Resolution: invalid
Keywords: get_option, database |
----------------------------------+----------------------
Comment (by garyc40):
Just in case you're still confused about the difference between in-memory
and persistent cache in WordPress:
Remember that the default object cache is not persistent, which means when
you start another request (by commenting via AJAX, or reloading the
dashboard), the cache is emptied and repopulated. Think of it as a
variable in a PHP file.
{{{
var_dump( $a ); // outputs null all the time, no matter how many times you
reload the page
$a = 1; // this value is only valid for this request, when you reload the
page, it's gone
}}}
Persistent cache on the other hand, preserve the cache across page
requests. Think of it like, saving {{{$a}}} to a file, and loading it back
in the subsequent requests:
{{{
if ( ! $a = read_from_file() )
$a = 0;
$a = ++;
save_to_file( $a );
}}}
Got the difference? WP_Object_Cache aims to be an in-memory cache, which
means its purpose is to save unnecessary db queries within each single
request. In that sense, it's working perfectly.
If you want the persistent behavior, install one of those plugins that you
mentioned.
Hope this makes sense.
Damn, I have too much time on my hand :)
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16287#comment:9>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list