While working on a module last night, I couldn't figure out why I couldn't get caching to work. I have done object caching at least a dozen times before but I couldn't figure out why I was not able to get the cached object back. Here's the code I was using:
<?php
if($cache = cache_get($cid, 'cache') && $cache->data) {
dsm('Cached!');
return $cache->data;
}
?>I finally realized that cache_get() was indeed returning a cache object, but the code inside the if statement was never executing.

