Answers.Body: <p>I think the function CRM_Core_Invoke::rebuildMenuAndCaches should also flush the memory caches, and hence call: CRM_Utils_System::flushCache( );</p>
  
  <p>This will make things more consistent and actually rebuild all caches as the function name suggests</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-24T14:23:08.360Z
Answers.Text: Can you edit and clarify your answer Lobo? Are you saying currently CRM_Core_Invoke::rebuildMenuAndCaches does not flush the memory caches? So if I want to clear the memory caches I need to call CRM_Utils_System::flushCache()? And should I create an issue to patch core?
Answers.UserDisplayName: herb
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-25T04:48:02.757Z
Answers.Text: yes, i would create an issue and submit a PR to add the changes to the rebuild function
Answers.UserDisplayName: Donald Lobo
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-24T03:28:53.390Z
Answers.LastActivityDate: 2015-05-24T03:28:53.390Z
Answers.UserDisplayName: Donald Lobo
Answers.Body: <p>Currently the function <code>CRM_Core_Invoke::rebuildMenuAndCaches</code> does <em>not</em> flush the memory caches, even though it will rebuild the database cache, menus and sessions. In order to also flush the memory caches you need to also call: <code>CRM_Utils_System::flushCache( );</code> (This was confirmed by Lobo but I think it needed to be written more explicitly as an <em>answer</em> and not as how things <em>should</em> be.)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-25T14:00:21.590Z
Answers.LastActivityDate: 2015-05-25T14:00:21.590Z
Answers.UserDisplayName: herb
Body: <p>I've seen from a <a href="https://civicrm.stackexchange.com/questions/93/what-are-the-different-caching-mechanisms-relevant-when-developing/96#96">different question</a> a suggestion to use <code>CRM_Core_Invoke::rebuildMenuAndCaches()</code> as the "granddaddy" of all cache flushing. However, I'd like to know if this is only clearing the cache in the database, such as <code>civicrm_cache</code> and so on or if it also clears non-database cache as well such as memcache.</p>
  
  <p>As far as I can tell the above function calls <code>CRM_Core_Config::cleanupCaches()</code> which calls <code>CRM_Core_Config::clearDBCache()</code> and that function truncates various cache tables. Am I missing something? How do the other caching backends get flushed?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-23T18:01:48.070Z
Comments.Text: I found this under api/v3/Job.php: `if ( $dbCache ) {
      CRM_Core_Config::clearDBCache( );
    } if ( $memCache ) {
      CRM_Utils_System::flushCache( );
    }` which seems to confirm my suspicion that there are two ways to clear the cache depending on what backend caching method is using.
Comments.UserDisplayName: herb
Tags: <cache>
Title: How does one flush the non-database cache (such as memcache) from CiviCRM code?
ThreadText: # How does one flush the non-database cache (such as memcache) from CiviCRM code?
  
  (Asked by: username_0 on 2015-05-22)
  
  I've seen from a [different question](https://civicrm.stackexchange.com/questions/93/what-are-the-different-caching-mechanisms-relevant-when-developing/96#96) a suggestion to use `CRM_Core_Invoke::rebuildMenuAndCaches()` as the "granddaddy" of all cache flushing. However, I'd like to know if this is only clearing the cache in the database, such as `civicrm_cache` and so on or if it also clears non-database cache as well such as memcache.
  
  As far as I can tell the above function calls `CRM_Core_Config::cleanupCaches()` which calls `CRM_Core_Config::clearDBCache()` and that function truncates various cache tables. Am I missing something? How do the other caching backends get flushed?
  
  **Tags:** cache
  
  > **Comments:**
  > **username_0**: I found this under api/v3/Job.php: `if ( $dbCache ) {     CRM_Core_Config::clearDBCache( );   } if ( $memCache ) {     CRM_Utils_System::flushCache( );   }` which seems to confirm my suspicion that there are two ways to clear the cache depending on what backend caching method is using.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2015-05-25. Score: 3 | Accepted answer
  
  Currently the function `CRM_Core_Invoke::rebuildMenuAndCaches` does *not* flush the memory caches, even though it will rebuild the database cache, menus and sessions. In order to also flush the memory caches you need to also call: `CRM_Utils_System::flushCache( );` (This was confirmed by username_1 but I think it needed to be written more explicitly as an *answer* and not as how things *should* be.)
  
  
  ---
  
  ### Answer by username_1 on 2015-05-24. Score: 2
  
  I think the function CRM\_Core\_Invoke::rebuildMenuAndCaches should also flush the memory caches, and hence call: CRM\_Utils\_System::flushCache( );
  
  This will make things more consistent and actually rebuild all caches as the function name suggests
  
  > **Comments:**
  > **username_0**: Can you edit and clarify your answer username_1? Are you saying currently CRM_Core_Invoke::rebuildMenuAndCaches does not flush the memory caches? So if I want to clear the memory caches I need to call CRM_Utils_System::flushCache()? And should I create an issue to patch core?  
  > **username_1**: yes, i would create an issue and submit a PR to add the changes to the rebuild function  
  
  ---
  
  