예제 #1
0
 /**
  * TransOpenApiAct::act_getCountryBySmall()
  * 根据标准英文国家名获取全部小语种国家并存入memcache
  * @param string $country 标准英文国家
  * @param int $is_new 是否强制更新,默认0不强制
  * @return  array;
  */
 public function act_getSmallCountryByEn()
 {
     $country = 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($country)) {
         self::$errCode = 10002;
         self::$errMsg = '标准英文国家参数错误!';
         return false;
     }
     $memc_obj = new Cache(C('CACHEGROUP'));
     $cacheName = md5("countries_en_small" . $country);
     $countryinfo = $memc_obj->get_extral($cacheName);
     if (!empty($countryinfo) && empty($is_new)) {
         return unserialize($countryinfo);
     } else {
         $countryinfo = TransOpenApiModel::getSmallCountryByEn($country);
         $isok = $memc_obj->set_extral($cacheName, serialize($countryinfo));
         if (!$isok) {
             self::$errCode = 10003;
             self::$errMsg = 'memcache缓存出错!';
             //return false;
         }
         return $countryinfo;
     }
 }