Пример #1
0
 /**
  * Checks the cache for the item with the specific hash, if it exists
  * it will be sent to the client using the content type that was
  * attached to the set() call.
  *
  * @param string $name The name of the object
  * @return boolean True if the object was returned from the cache
  */
 function get($name)
 {
     $hash = md5($name);
     $base = config::get('lepton.fscache.path', 'cache');
     $db = DBX::getInstance(DBX);
     $db->getSchemaManager()->checkSchema('fscache');
     $rs = $db->getSingleRow("SELECT contenttype,expires FROM fscache WHERE hash='%s'", $hash);
     if ($rs) {
         if (!file_exists($base . '/' . $hash) || time() > $rs['expires']) {
             @unlink($base . '/' . $hash);
             $db->updateRow("DELETE FROM fscache WHERE hash='%s'", $hash);
             return false;
         } else {
             response::contentType($rs['contenttype']);
             response::sendFile($base . '/' . $hash);
             return true;
         }
     } else {
         return false;
     }
 }