private static function getMysqlCacheUnlessIsOldOrDoesNotExist($name, $cacheFor) { if (!$cacheFor) { return false; } $md5 = md5($name); if (isset(self::$inMem[$md5])) { clAPI::debug("MySQL cache <b>{$md5}</b> found in memory! Now that's fast."); return self::$inMem[$md5]; } if (self::initMySql()) { $cacheFor = date('Y/m/d H:i:s', self::parseCacheFor($cacheFor)); clAPI::debug("Querying MySQL for cached content named <b>{$md5}</b> cached no earlier than <b>{$cacheFor}</b>."); $content = self::getVar("SELECT content FROM `" . self::cacheTableName() . "` WHERE id='{$md5}' AND '{$cacheFor}' < cached_on"); if ($error = mysql_error(self::$mysqlConnection)) { clAPI::error('Failed to query the database for cached content. See error log for details'); error_log('Failed to query the database for cached content: ' . $error); return false; } else { if ($content === null) { clAPI::debug("No MySQL cached content found for <b>{$md5}</b>"); return false; } else { clAPI::debug("MySQL cached content found for <b>{$md5}</b>. Yippie!"); self::$inMem[$md5] = $content; return $content; } } } else { return false; } }