[CakePHP] Disable Model Queries Caching

Again a simple tip. CakePHP by default, in order to optimize performance, has a query caching system. This is a very cool feature but sometimes it may be self-defeating. For example when you do queries for Unit Testing.

In order to disable query caching, it’s enough to set the model cacheQueries variable to false. Setting it to true will re-enable queries caching.

You can disable it for the whole model “life-time” setting it during “design time”

class Project extends AppModel {
var $name = "Project";
var $customValidate = array("name");
var $cacheQueries = false;

or you can temporarily disable it by calling the $this->Model->cacheQueries=false (use your model instead of “Model”)