Ejemplo n.º 1
0
 public static function call($service, $params = array())
 {
     // 缓存时间,大于0时才缓存
     $queryCachingDuration = F::sg('cache', 'jpdataCachingDuration');
     if ($queryCachingDuration > 0 && self::isCacheService($service)) {
         $cache = Yii::app()->cache;
         $cache_key = self::createCacheKey($service, $params);
         $cache_value = $cache->get($cache_key);
         if ($cache_value) {
             return $cache_value;
         }
     }
     //依据service调用不同的方法
     $result = APIServer::executeService($service, $params);
     // 设置缓存
     if ($queryCachingDuration > 0 && !empty($result)) {
         $cache = Yii::app()->cache;
         $cache->set($cache_key, $result);
     }
     if (is_null($result)) {
         $result = array();
     }
     return $result;
 }