Ejemplo n.º 1
0
 /**
  * TransOpenApiAct::act_getCountriesStandard()
  * 获取全部或部分标准国家并存入mencache
  * @param string $type ALL全部,CN中文,EN英文
  * @param string $country 国家,默认空
  * @param int $is_new 是否强制更新(默认0不强制)
  * @return  array 
  */
 public function act_getCountriesStandard()
 {
     $type = isset($_REQUEST['type']) ? post_check($_REQUEST['type']) : "ALL";
     $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 (!in_array($type, array("ALL", "EN", "CN"))) {
         self::$errCode = 309;
         self::$errMsg = '参数TYPE类型错误!';
         return false;
     }
     if ($type == "ALL") {
         $country = "";
     }
     //防止重复CACHE
     $cacheName = md5("trans_countries_standard_{$type}{$country}");
     $memc_obj = new Cache(C('CACHEGROUP'));
     $countriesInfo = $memc_obj->get_extral($cacheName);
     if (!empty($countriesInfo) && empty($is_new)) {
         return unserialize($countriesInfo);
     } else {
         if ($type == "ALL") {
             $countriesInfo = TransOpenApiModel::getCountriesStandard();
         } else {
             $countriesInfo = TransOpenApiModel::getCountriesStandard($type, $country);
         }
         $isok = $memc_obj->set_extral($cacheName, serialize($countriesInfo));
         if (!$isok) {
             self::$errCode = 308;
             self::$errMsg = 'memcache缓存出错!';
             //return false;
         }
         return $countriesInfo;
     }
 }