title: How to check for empty result set vs. unset key in Memcached in CakePHP
body: <p>I'm using Memcached in a CakePHP application to cache MySQL result sets.  One result set that I'm caching is empty about half the time.</p>
  
  <p>The problem I'm having is that when the result set is empty and I set the Memcached key, it sets the empty/false result from CakePHP's find method.</p>
  
  <p>When I check the Memcached key in my script on the next page load, it runs the query again because reading the Memcached key's value must return false.</p>
  
  <p>Here's my general Memcached logic using the CakePHP Cache utility:</p>
  
  <pre><code>if(!$resultsArray = Cache::read('results_array')) {  
      $resultsArray = $this-&gt;Model-&gt;find('all', $params);
      Cache::write('results_array', $resultsArray);
  }
  </code></pre>
  
  <p>What's the best practice to check the cache to distinguish between a Memcached key that doesn't exist and a key that contains a false/empty value from a previous find function?  (maybe this is more about PHP/programming than Memcached).</p>