/** * TransOpenApiAct::act_getCountryBySmall() * 用小语种国家名取得英文国家名并存入mencache * @param string $country 小语种国家 * @param int $is_new 是否强制更新,默认0不强制 * @return string 英文国家名; */ public function act_getCountryBySmall() { $smallCountry = isset($_REQUEST['country']) ? post_check($_REQUEST['country']) : ""; $is_new = isset($_REQUEST['is_new']) ? $_REQUEST['is_new'] : 0; if (!in_array($is_new, array(0, 1))) { self::$errCode = 10001; self::$errMsg = '强制更新参数有误!'; return false; } if (empty($smallCountry)) { self::$errCode = 10002; self::$errMsg = '小语种国家参数传递错误!'; return false; } $memc_obj = new Cache(C('CACHEGROUP')); $cacheName = md5("countries_small_comparson" . $smallCountry); $countryinfo = $memc_obj->get_extral($cacheName); if (!empty($countryinfo) && empty($is_new)) { return unserialize($countryinfo); } else { $countryinfo = TransOpenApiModel::getCountryBySmall($smallCountry); $isok = $memc_obj->set_extral($cacheName, serialize($countryinfo)); if (!$isok) { self::$errCode = 10003; self::$errMsg = 'memcache缓存出错!'; //return false; } return $countryinfo; } }