Пример #1
0
 public static function getRecipeById($dataId)
 {
     $cache = CacheHandler::getInstance('recipe_gw2api');
     $cacheKey = $dataId . "::" . substr(md5($dataId), 0, 10);
     $ttl = 86400;
     if (!($API_JSON = $cache->get($cacheKey))) {
         try {
             $curl_item = CurlRequest::newInstance(getAppConfig('gw2spidy.gw2api_url') . "/v1/recipe_details.json?recipe_id={$dataId}")->exec();
             $API_JSON = $curl_item->getResponseBody();
             $cache->set($cacheKey, $API_JSON, MEMCACHE_COMPRESSED, $ttl);
         } catch (\Exception $e) {
             $ttl = 600;
             $cache->set($cacheKey, null, MEMCACHE_COMPRESSED, $ttl);
             return null;
         }
     }
     return APIRecipe::getRecipeByJSON($API_JSON);
 }