Clear data stored with drupal_static() and cache_set() I have a custom module in Drupal 7 where I am caching data from REST calls using drupal_static() and cache_set().

function _mymodule_call() {
  $data = &amp;drupal_static(__FUNCTION__);
  if ( ! isset($data) ) {
    if ($cache = cache_get(__FUNCTION__)) {
      $data = $cache-&gt;data;
    }
    else {
      $data = my_api_call();

      if ( is_object($lists) ) {
        // cache for one hour
        cache_set(__FUNCTION__, $data, 'cache', time() + 3600);
      }
    }
  }
  return $data;
}


I want to make an admin feature where we can specifically clear these cached values. I suppose the cache key would be _mymodule_call. How do I clear them from the cache?
The Drupal way is to have a $reset parameter to your function.  It would look something like:

function _mymodule_call($reset = FALSE) {
  if ($reset) {
    // do stuff
  }
  // ...
}


node_load() is probably the best example of this.

In your specific case, you can pass the $reset parameter to drupal_static() or explicitly call drupal_static_reset().  For the cache backend, you need to think whether you want to just rework the logic and just do the cache_set() or explicitly call cache_clear_all($cid) (my guess is the former).

And remember, that drupal_static() is only effective when you need the value multiple times during the same request.  This does not persist between page loads (or any other HTTP request that get handled by Drupal).