WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to guarantee that when I call get_option I will definitely get the value from the database and not from cache?

share|improve this question
up vote 2 down vote accepted

You could delete an existing cache for your option before you call get_option():

$GLOBALS['wp_object_cache']->delete( 'your_option_name', 'options' );
$value = get_option( 'your_option_name' );
share|improve this answer
not wp_cache_delete()? – djb May 20 '13 at 9:59
ah, it's the same anyway. thanks – djb May 20 '13 at 10:24

Using the wp_cache_delete() technic showcased by toscho, you also have to make sure your option is not on autoload. If your option is autoloaded, it'll be part of the alloptions cache so you won't be able to clear it individually.

So make sure to use the following format when you set/update your option if you want to be able to clear it from the cache:

update_option( 'my_key', 'my val', false ); // False being the autoload parameter

add_option( 'my_key', 'my val', null, false ); // null is a deprecated argument.

update_option() documentation

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.