[wp-hackers] Questions about the Cache
Ryan Boren
ryan at boren.nu
Tue Jul 25 20:59:21 GMT 2006
Brian Layman wrote:
>> I got my article posted on Friday:
>> http://dougal.gunters.org/blog/2006/07/21/using-the-wordpress-object-cache
>
> I'm glad you informed the list.
>
> Good article. Thank you.
>
> I am assuming that wp_cache_get() will return FALSE, if ENABLE_CACHE is not
> defined. So, it is safe to write the code directly using wp_cache_get
> rather than checking the ENABLE_CACHE value every time. Is that correct?
ENABLE_CACHE means that "persistent" caching is enabled. Even if the
persistent cache is disabled, the in-memory cache that is tossed with
each page load is still operational. wp_cache_get() will retrieve
values from that in-memory cache. A typical page load does
get_option('siteurl') many times. If we didn't cache the siteurl value
to memory, we would have to make dozens of round trips to the DB.
ENABLE_CACHE and DISABLE_CACHE aren't part of the API and shouldn't be
used in plugins. They are simply wp-config settings that control the
default cache.
Ryan
More information about the wp-hackers
mailing list