Answers.Body: <p>Craft is using the default Yii <a href="https://www.yiiframework.com/doc/api/2.0/yii-db-connection#$queryCache-detail" rel="nofollow noreferrer">queryCache</a> component, which is set to the file system cache by default (i.e., what's in <code>storage/runtime/cache</code>.</p>
  
  <p>There's no way to clear specific items in that cache, but you can clear all of it with <code>Craft::$app-&gt;getCache()-&gt;flush()</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-08T18:24:32.017Z
Answers.Text: Is there a way that I can instead perform a query and have it overlook the cache? I tried doing something like ``$entry->categoryField->noCache()->orderBy('level', 'desc')->one()`` but it still seems to pull the results from the cache and they are ordered by level, ascending.
Answers.UserDisplayName: Benjamin Kohl
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-08T01:43:27.767Z
Answers.LastActivityDate: 2019-08-08T01:43:27.767Z
Answers.UserDisplayName: Brad Bell
Body: <p>How do I flush Craft's query cache so that I may query a relationship field again in the same web request with a new set of parameters? In this particular scenario, I need to handle it inside of a custom module so I need PHP and not Twig.</p>
  
  <p>Yes, I am fully aware of cloning the original query in order to make a second query with modified parameters so do not mention that in your answer. It is not an option in this scenario and it does not answer my question.</p>
  
Tags: <relations><cache><elementquery>
Title: How do I flush the query cache?
ThreadText: # How do I flush the query cache?
  
  (Asked by: username_0 on 2019-08-07)
  
  How do I flush Craft's query cache so that I may query a relationship field again in the same web request with a new set of parameters? In this particular scenario, I need to handle it inside of a custom module so I need PHP and not Twig.
  
  Yes, I am fully aware of cloning the original query in order to make a second query with modified parameters so do not mention that in your answer. It is not an option in this scenario and it does not answer my question.
  
  **Tags:** relations, cache, elementquery
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-08-08. Score: 0
  
  Craft is using the default Yii [queryCache](https://www.yiiframework.com/doc/api/2.0/yii-db-connection#$queryCache-detail) component, which is set to the file system cache by default (i.e., what's in `storage/runtime/cache`.
  
  There's no way to clear specific items in that cache, but you can clear all of it with `Craft::$app->getCache()->flush()`.
  
  > **Comments:**
  > **username_0**: Is there a way that I can instead perform a query and have it overlook the cache? I tried doing something like ``$entry->categoryField->noCache()->orderBy('level', 'desc')->one()`` but it still seems to pull the results from the cache and they are ordered by level, ascending.  
  
  ---
  
  