Esempio n. 1
0
 /**
  * Get news by rule 3 : folder X + subfolder X  => order by publish_time
  * @param array $arrParams
  *      $arrParams['category_id'] int
  *      $arrParams['offset'] int
  *      $arrParams['limit'] int
  *      $arrParams['withcore'] boolean
  * @return array
  * @author HungNT1
  */
 public function getListArticleIdsByRule3($arrParams)
 {
     //default return
     $arrReturn = array('total' => 0, 'data' => array());
     try {
         //get instance redis
         $redisInstance = Thethao_Global::getRedis('article');
         if ($redisInstance) {
             //make key cache
             $keyCache = vsprintf($this->_list_article_ids_by_rule_3, array($arrParams['category_id'], intval($arrParams['article_type'])));
             //get total of this key
             $arrReturn['total'] = intval($redisInstance->get($keyCache . ':total'));
             //check total data
             if ($arrReturn['total'] > 0 && $arrParams['offset'] < $arrReturn['total']) {
                 //get end score
                 $end = Thethao_Global::getRedisPaging($arrParams['offset'], $arrParams['limit']);
                 //get revert score: latest will be show first
                 $arrReturn['data'] = $redisInstance->zRevRange($keyCache, $arrParams['offset'], $end, $arrParams['withcore']);
             }
         }
     } catch (Exception $ex) {
         //writelog error
         Thethao_Global::sendLog($ex);
     }
     return $arrReturn;
 }