예제 #1
0
 /**
  * Получить комменты по рейтингу и дате
  *
  * @param  string $sDate          Дата за которую выводить рейтинг, т.к. кеширование происходит по дате, то дату лучше передавать с точностью до часа (минуты и секунды как 00:00)
  * @param  string $sTargetType    Тип владельца комментария
  * @param  int    $iLimit         Количество элементов
  *
  * @return array
  */
 public function GetCommentsRatingByDate($sDate, $sTargetType, $iLimit = 20)
 {
     /**
      * Выбираем топики, комметарии к которым являются недоступными для пользователя
      */
     $aCloseBlogs = $this->oUserCurrent ? E::ModuleBlog()->GetInaccessibleBlogsByUser($this->oUserCurrent) : E::ModuleBlog()->GetInaccessibleBlogsByUser();
     $sCacheKey = "comment_rating_{$sDate}_{$sTargetType}_{$iLimit}_" . serialize($aCloseBlogs);
     /**
      * Т.к. время передаётся с точностью 1 час то можно по нему замутить кеширование
      */
     if (false === ($data = E::ModuleCache()->Get($sCacheKey))) {
         $data = $this->oMapper->GetCommentsIdByRatingAndDate($sDate, $sTargetType, $iLimit, array(), $aCloseBlogs);
         E::ModuleCache()->Set($data, $sCacheKey, array("comment_new_{$sTargetType}", "comment_update_status_{$sTargetType}", "comment_update_rating_{$sTargetType}"), 'P2D');
     }
     if ($data) {
         $data = $this->GetCommentsAdditionalData($data);
     }
     return $data;
 }