mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-07-01 05:55:02 +03:00
This commit is contained in:
parent
2e04556aea
commit
2cf432bdbd
|
@ -130,6 +130,11 @@ class ActionPeople extends Action {
|
|||
*
|
||||
*/
|
||||
protected function EventOnline() {
|
||||
/**
|
||||
* Последние по визиту на сайт
|
||||
*/
|
||||
$aUsersLast=$this->User_GetUsersByDateLast(15);
|
||||
$this->Viewer_Assign('aUsersLast',$aUsersLast);
|
||||
/**
|
||||
* Получаем статистику
|
||||
*/
|
||||
|
@ -140,6 +145,11 @@ class ActionPeople extends Action {
|
|||
*
|
||||
*/
|
||||
protected function EventNew() {
|
||||
/**
|
||||
* Последние по регистрации
|
||||
*/
|
||||
$aUsersRegister=$this->User_GetUsersByDateRegister(15);
|
||||
$this->Viewer_Assign('aUsersRegister',$aUsersRegister);
|
||||
/**
|
||||
* Получаем статистику
|
||||
*/
|
||||
|
@ -186,14 +196,6 @@ class ActionPeople extends Action {
|
|||
*
|
||||
*/
|
||||
protected function GetStats() {
|
||||
/**
|
||||
* Последние по визиту на сайт
|
||||
*/
|
||||
$aUsersLast=$this->User_GetUsersByDateLast(15);
|
||||
/**
|
||||
* Последние по регистрации
|
||||
*/
|
||||
$aUsersRegister=$this->User_GetUsersByDateRegister(15);
|
||||
/**
|
||||
* Статистика кто, где и т.п.
|
||||
*/
|
||||
|
@ -201,8 +203,6 @@ class ActionPeople extends Action {
|
|||
/**
|
||||
* Загружаем переменные в шаблон
|
||||
*/
|
||||
$this->Viewer_Assign('aUsersLast',$aUsersLast);
|
||||
$this->Viewer_Assign('aUsersRegister',$aUsersRegister);
|
||||
$this->Viewer_Assign('aStat',$aStat);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -106,6 +106,12 @@ class LsBlog extends Module {
|
|||
* @param array $aUserId
|
||||
*/
|
||||
public function GetBlogsByArrayId($aBlogId) {
|
||||
if (!$aBlogId) {
|
||||
return array();
|
||||
}
|
||||
if (1) {
|
||||
return $this->GetBlogsByArrayIdSolid($aBlogId);
|
||||
}
|
||||
if (!is_array($aBlogId)) {
|
||||
$aBlogId=array($aBlogId);
|
||||
}
|
||||
|
@ -116,7 +122,7 @@ class LsBlog extends Module {
|
|||
* Делаем мульти-запрос к кешу
|
||||
*/
|
||||
$aCacheKeys=func_build_cache_keys($aBlogId,'blog_');
|
||||
if (0 and false !== ($data = $this->Cache_Get($aCacheKeys))) {
|
||||
if (false !== ($data = $this->Cache_Get($aCacheKeys))) {
|
||||
/**
|
||||
* проверяем что досталось из кеша
|
||||
*/
|
||||
|
@ -142,7 +148,7 @@ class LsBlog extends Module {
|
|||
* Добавляем к результату и сохраняем в кеш
|
||||
*/
|
||||
$aBlogs[$oBlog->getId()]=$oBlog;
|
||||
//$this->Cache_Set($oBlog, "blog_{$oBlog->getId()}", array(), 60*60*24*4);
|
||||
$this->Cache_Set($oBlog, "blog_{$oBlog->getId()}", array(), 60*60*24*4);
|
||||
$aBlogIdNeedStore=array_diff($aBlogIdNeedStore,array($oBlog->getId()));
|
||||
}
|
||||
}
|
||||
|
@ -158,6 +164,29 @@ class LsBlog extends Module {
|
|||
$aBlogs=func_array_sort_by_keys($aBlogs,$aBlogId);
|
||||
return $aBlogs;
|
||||
}
|
||||
/**
|
||||
* Список блогов по ID, но используя единый кеш
|
||||
*
|
||||
* @param unknown_type $aBlogId
|
||||
* @return unknown
|
||||
*/
|
||||
public function GetBlogsByArrayIdSolid($aBlogId) {
|
||||
if (!is_array($aBlogId)) {
|
||||
$aBlogId=array($aBlogId);
|
||||
}
|
||||
$aBlogId=array_unique($aBlogId);
|
||||
$aBlogs=array();
|
||||
$s=join(',',$aBlogId);
|
||||
if (false === ($data = $this->Cache_Get("blog_id_{$s}"))) {
|
||||
$data = $this->oMapperBlog->GetBlogsByArrayId($aBlogId);
|
||||
foreach ($data as $oBlog) {
|
||||
$aBlogs[$oBlog->getId()]=$oBlog;
|
||||
}
|
||||
$this->Cache_Set($aBlogs, "blog_id_{$s}", array("blog_update"), 60*60*24*1);
|
||||
return $aBlogs;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* Получить персональный блог юзера
|
||||
*
|
||||
|
@ -206,7 +235,7 @@ class LsBlog extends Module {
|
|||
public function GetBlogByTitle($sTitle) {
|
||||
if (false === ($id = $this->Cache_Get("blog_title_{$sTitle}"))) {
|
||||
if ($id = $this->oMapperBlog->GetBlogByTitle($sTitle)) {
|
||||
$this->Cache_Set($id, "blog_title_{$sTitle}", array("blog_update_{$data->getId()}",'blog_new'), 60*60*24*2);
|
||||
$this->Cache_Set($id, "blog_title_{$sTitle}", array("blog_update_{$id}",'blog_new'), 60*60*24*2);
|
||||
} else {
|
||||
$this->Cache_Set(null, "blog_title_{$sTitle}", array('blog_update','blog_new'), 60*60);
|
||||
}
|
||||
|
@ -431,6 +460,12 @@ class LsBlog extends Module {
|
|||
* @param unknown_type $aTopicId
|
||||
*/
|
||||
public function GetBlogUsersByArrayBlog($aBlogId,$sUserId) {
|
||||
if (!$aBlogId) {
|
||||
return array();
|
||||
}
|
||||
if (1) {
|
||||
return $this->GetBlogUsersByArrayBlogSolid($aBlogId,$sUserId);
|
||||
}
|
||||
if (!is_array($aBlogId)) {
|
||||
$aBlogId=array($aBlogId);
|
||||
}
|
||||
|
@ -483,7 +518,23 @@ class LsBlog extends Module {
|
|||
$aBlogUsers=func_array_sort_by_keys($aBlogUsers,$aBlogId);
|
||||
return $aBlogUsers;
|
||||
}
|
||||
|
||||
public function GetBlogUsersByArrayBlogSolid($aBlogId,$sUserId) {
|
||||
if (!is_array($aBlogId)) {
|
||||
$aBlogId=array($aBlogId);
|
||||
}
|
||||
$aBlogId=array_unique($aBlogId);
|
||||
$aBlogUsers=array();
|
||||
$s=join(',',$aBlogId);
|
||||
if (false === ($data = $this->Cache_Get("blog_relation_user_{$sUserId}_id_{$s}"))) {
|
||||
$data = $this->oMapperBlog->GetBlogUsersByArrayBlog($aBlogId,$sUserId);
|
||||
foreach ($data as $oBlogUser) {
|
||||
$aBlogUsers[$oBlogUser->getBlogId()]=$oBlogUser;
|
||||
}
|
||||
$this->Cache_Set($aBlogUsers, "blog_relation_user_{$sUserId}_id_{$s}", array("blog_relation_change_{$sUserId}"), 60*60*24*1);
|
||||
return $aBlogUsers;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function UpdateRelationBlogUser(BlogEntity_BlogUser $oBlogUser) {
|
||||
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("blog_relation_change_{$oBlogUser->getUserId()}","blog_relation_change_blog_{$oBlogUser->getBlogId()}"));
|
||||
$this->Cache_Delete("blog_relation_user_{$oBlogUser->getBlogId()}_{$oBlogUser->getUserId()}");
|
||||
|
@ -500,7 +551,7 @@ class LsBlog extends Module {
|
|||
$data = array('collection'=>$this->oMapperBlog->GetBlogsRating($iCount,$iCurrPage,$iPerPage),'count'=>$iCount);
|
||||
$this->Cache_Set($data, "blog_rating_{$iCurrPage}_{$iPerPage}", array("blog_update","blog_new"), 60*60*24*2);
|
||||
}
|
||||
$data['collection']=$this->GetBlogsAdditionalData($data['collection'],array('owner'=>array()));
|
||||
$data['collection']=$this->GetBlogsAdditionalData($data['collection'],array('owner'=>array(),'relation_user'));
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -146,6 +146,12 @@ class LsComment extends Module {
|
|||
* @param array $aUserId
|
||||
*/
|
||||
public function GetCommentsByArrayId($aCommentId) {
|
||||
if (!$aCommentId) {
|
||||
return array();
|
||||
}
|
||||
if (1) {
|
||||
return $this->GetCommentsByArrayIdSolid($aCommentId);
|
||||
}
|
||||
if (!is_array($aCommentId)) {
|
||||
$aCommentId=array($aCommentId);
|
||||
}
|
||||
|
@ -156,7 +162,7 @@ class LsComment extends Module {
|
|||
* Делаем мульти-запрос к кешу
|
||||
*/
|
||||
$aCacheKeys=func_build_cache_keys($aCommentId,'comment_');
|
||||
if (0 and false !== ($data = $this->Cache_Get($aCacheKeys))) {
|
||||
if (false !== ($data = $this->Cache_Get($aCacheKeys))) {
|
||||
/**
|
||||
* проверяем что досталось из кеша
|
||||
*/
|
||||
|
@ -182,7 +188,7 @@ class LsComment extends Module {
|
|||
* Добавляем к результату и сохраняем в кеш
|
||||
*/
|
||||
$aComments[$oComment->getId()]=$oComment;
|
||||
//$this->Cache_Set($oComment, "comment_{$oComment->getId()}", array(), 60*60*24*4);
|
||||
$this->Cache_Set($oComment, "comment_{$oComment->getId()}", array(), 60*60*24*4);
|
||||
$aCommentIdNeedStore=array_diff($aCommentIdNeedStore,array($oComment->getId()));
|
||||
}
|
||||
}
|
||||
|
@ -198,6 +204,23 @@ class LsComment extends Module {
|
|||
$aComments=func_array_sort_by_keys($aComments,$aCommentId);
|
||||
return $aComments;
|
||||
}
|
||||
public function GetCommentsByArrayIdSolid($aCommentId) {
|
||||
if (!is_array($aCommentId)) {
|
||||
$aCommentId=array($aCommentId);
|
||||
}
|
||||
$aCommentId=array_unique($aCommentId);
|
||||
$aComments=array();
|
||||
$s=join(',',$aCommentId);
|
||||
if (false === ($data = $this->Cache_Get("comment_id_{$s}"))) {
|
||||
$data = $this->oMapper->GetCommentsByArrayId($aCommentId);
|
||||
foreach ($data as $oComment) {
|
||||
$aComments[$oComment->getId()]=$oComment;
|
||||
}
|
||||
$this->Cache_Set($aComments, "comment_id_{$s}", array("comment_update"), 60*60*24*1);
|
||||
return $aComments;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* Получть все комменты сгрупированные по топику(для вывода прямого эфира)
|
||||
*
|
||||
|
@ -307,7 +330,7 @@ class LsComment extends Module {
|
|||
public function UpdateComment(CommentEntity_Comment $oComment) {
|
||||
if ($this->oMapper->UpdateComment($oComment)) {
|
||||
//чистим зависимые кеши
|
||||
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("comment_update_{$oComment->getId()}","comment_update_{$oComment->getTargetType()}","comment_update_{$oComment->getTargetType()}_{$oComment->getTargetId()}"));
|
||||
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("comment_update","comment_update_{$oComment->getId()}","comment_update_{$oComment->getTargetType()}","comment_update_{$oComment->getTargetType()}_{$oComment->getTargetId()}"));
|
||||
$this->Cache_Delete("comment_{$oComment->getId()}");
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -248,6 +248,13 @@ class LsTopic extends Module {
|
|||
* @param unknown_type $aTopicId
|
||||
*/
|
||||
public function GetTopicsByArrayId($aTopicId) {
|
||||
if (!$aTopicId) {
|
||||
return array();
|
||||
}
|
||||
if (1) {
|
||||
return $this->GetTopicsByArrayIdSolid($aTopicId);
|
||||
}
|
||||
|
||||
if (!is_array($aTopicId)) {
|
||||
$aTopicId=array($aTopicId);
|
||||
}
|
||||
|
@ -258,7 +265,7 @@ class LsTopic extends Module {
|
|||
* Делаем мульти-запрос к кешу
|
||||
*/
|
||||
$aCacheKeys=func_build_cache_keys($aTopicId,'topic_');
|
||||
if (1 and false !== ($data = $this->Cache_Get($aCacheKeys))) {
|
||||
if (false !== ($data = $this->Cache_Get($aCacheKeys))) {
|
||||
/**
|
||||
* проверяем что досталось из кеша
|
||||
*/
|
||||
|
@ -300,6 +307,29 @@ class LsTopic extends Module {
|
|||
$aTopics=func_array_sort_by_keys($aTopics,$aTopicId);
|
||||
return $aTopics;
|
||||
}
|
||||
/**
|
||||
* Получить список топиков по списку айдишников, но используя единый кеш
|
||||
*
|
||||
* @param unknown_type $aTopicId
|
||||
* @return unknown
|
||||
*/
|
||||
public function GetTopicsByArrayIdSolid($aTopicId) {
|
||||
if (!is_array($aTopicId)) {
|
||||
$aTopicId=array($aTopicId);
|
||||
}
|
||||
$aTopicId=array_unique($aTopicId);
|
||||
$aTopics=array();
|
||||
$s=join(',',$aTopicId);
|
||||
if (false === ($data = $this->Cache_Get("topic_id_{$s}"))) {
|
||||
$data = $this->oMapperTopic->GetTopicsByArrayId($aTopicId);
|
||||
foreach ($data as $oTopic) {
|
||||
$aTopics[$oTopic->getId()]=$oTopic;
|
||||
}
|
||||
$this->Cache_Set($aTopics, "topic_id_{$s}", array("topic_update"), 60*60*24*1);
|
||||
return $aTopics;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* Получает список топиков из избранного
|
||||
*
|
||||
|
@ -694,6 +724,12 @@ class LsTopic extends Module {
|
|||
* @param unknown_type $aTopicId
|
||||
*/
|
||||
public function GetFavouriteTopicsByArray($aTopicId,$sUserId) {
|
||||
if (!$aTopicId) {
|
||||
return array();
|
||||
}
|
||||
if (1) {
|
||||
return $this->GetFavouriteTopicsByArraySolid($aTopicId,$sUserId);
|
||||
}
|
||||
if (!is_array($aTopicId)) {
|
||||
$aTopicId=array($aTopicId);
|
||||
}
|
||||
|
@ -746,6 +782,30 @@ class LsTopic extends Module {
|
|||
$aFavouriteTopics=func_array_sort_by_keys($aFavouriteTopics,$aTopicId);
|
||||
return $aFavouriteTopics;
|
||||
}
|
||||
/**
|
||||
* Получить список избранного по списку айдишников, но используя единый кеш
|
||||
*
|
||||
* @param array $aTopicId
|
||||
* @param int $sUserId
|
||||
* @return array
|
||||
*/
|
||||
public function GetFavouriteTopicsByArraySolid($aTopicId,$sUserId) {
|
||||
if (!is_array($aTopicId)) {
|
||||
$aTopicId=array($aTopicId);
|
||||
}
|
||||
$aTopicId=array_unique($aTopicId);
|
||||
$aFavouriteTopics=array();
|
||||
$s=join(',',$aTopicId);
|
||||
if (false === ($data = $this->Cache_Get("favourite_topic_{$sUserId}_id_{$s}"))) {
|
||||
$data = $this->oMapperTopic->GetFavouriteTopicsByArray($aTopicId,$sUserId);
|
||||
foreach ($data as $oFavouriteTopic) {
|
||||
$aFavouriteTopics[$oFavouriteTopic->getTopicId()]=$oFavouriteTopic;
|
||||
}
|
||||
$this->Cache_Set($aFavouriteTopics, "favourite_topic_{$sUserId}_id_{$s}", array("favourite_topic_change_user_{$sUserId}"), 60*60*24*1);
|
||||
return $aFavouriteTopics;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* Добавляет топик в избранное
|
||||
*
|
||||
|
@ -795,9 +855,11 @@ class LsTopic extends Module {
|
|||
public function SetTopicRead(TopicEntity_TopicRead $oTopicRead) {
|
||||
if ($this->GetTopicRead($oTopicRead->getTopicId(),$oTopicRead->getUserId())) {
|
||||
$this->Cache_Delete("topic_read_{$oTopicRead->getTopicId()}_{$oTopicRead->getUserId()}");
|
||||
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("topic_read_user_{$oTopicRead->getUserId()}"));
|
||||
$this->oMapperTopic->UpdateTopicRead($oTopicRead);
|
||||
} else {
|
||||
$this->Cache_Delete("topic_read_{$oTopicRead->getTopicId()}_{$oTopicRead->getUserId()}");
|
||||
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("topic_read_user_{$oTopicRead->getUserId()}"));
|
||||
$this->oMapperTopic->AddTopicRead($oTopicRead);
|
||||
}
|
||||
return true;
|
||||
|
@ -822,6 +884,12 @@ class LsTopic extends Module {
|
|||
* @param unknown_type $aTopicId
|
||||
*/
|
||||
public function GetTopicsReadByArray($aTopicId,$sUserId) {
|
||||
if (!$aTopicId) {
|
||||
return array();
|
||||
}
|
||||
if (1) {
|
||||
return $this->GetTopicsReadByArraySolid($aTopicId,$sUserId);
|
||||
}
|
||||
if (!is_array($aTopicId)) {
|
||||
$aTopicId=array($aTopicId);
|
||||
}
|
||||
|
@ -874,6 +942,30 @@ class LsTopic extends Module {
|
|||
$aTopicsRead=func_array_sort_by_keys($aTopicsRead,$aTopicId);
|
||||
return $aTopicsRead;
|
||||
}
|
||||
/**
|
||||
* Получить список просмотром/чтения топиков по списку айдишников, но используя единый кеш
|
||||
*
|
||||
* @param unknown_type $aTopicId
|
||||
* @param unknown_type $sUserId
|
||||
* @return unknown
|
||||
*/
|
||||
public function GetTopicsReadByArraySolid($aTopicId,$sUserId) {
|
||||
if (!is_array($aTopicId)) {
|
||||
$aTopicId=array($aTopicId);
|
||||
}
|
||||
$aTopicId=array_unique($aTopicId);
|
||||
$aTopicsRead=array();
|
||||
$s=join(',',$aTopicId);
|
||||
if (false === ($data = $this->Cache_Get("topic_read_{$sUserId}_id_{$s}"))) {
|
||||
$data = $this->oMapperTopic->GetTopicsReadByArray($aTopicId,$sUserId);
|
||||
foreach ($data as $oTopicRead) {
|
||||
$aTopicsRead[$oTopicRead->getTopicId()]=$oTopicRead;
|
||||
}
|
||||
$this->Cache_Set($aTopicsRead, "topic_read_{$sUserId}_id_{$s}", array("topic_read_user_{$sUserId}"), 60*60*24*1);
|
||||
return $aTopicsRead;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* Проверяет голосовал ли юзер за топик-вопрос
|
||||
*
|
||||
|
@ -894,6 +986,12 @@ class LsTopic extends Module {
|
|||
* @param unknown_type $aTopicId
|
||||
*/
|
||||
public function GetTopicsQuestionVoteByArray($aTopicId,$sUserId) {
|
||||
if (!$aTopicId) {
|
||||
return array();
|
||||
}
|
||||
if (1) {
|
||||
return $this->GetTopicsQuestionVoteByArraySolid($aTopicId,$sUserId);
|
||||
}
|
||||
if (!is_array($aTopicId)) {
|
||||
$aTopicId=array($aTopicId);
|
||||
}
|
||||
|
@ -946,6 +1044,30 @@ class LsTopic extends Module {
|
|||
$aTopicsQuestionVote=func_array_sort_by_keys($aTopicsQuestionVote,$aTopicId);
|
||||
return $aTopicsQuestionVote;
|
||||
}
|
||||
/**
|
||||
* Получить список голосований в топике-опросе по списку айдишников, но используя единый кеш
|
||||
*
|
||||
* @param unknown_type $aTopicId
|
||||
* @param unknown_type $sUserId
|
||||
* @return unknown
|
||||
*/
|
||||
public function GetTopicsQuestionVoteByArraySolid($aTopicId,$sUserId) {
|
||||
if (!is_array($aTopicId)) {
|
||||
$aTopicId=array($aTopicId);
|
||||
}
|
||||
$aTopicId=array_unique($aTopicId);
|
||||
$aTopicsQuestionVote=array();
|
||||
$s=join(',',$aTopicId);
|
||||
if (false === ($data = $this->Cache_Get("topic_question_vote_{$sUserId}_id_{$s}"))) {
|
||||
$data = $this->oMapperTopic->GetTopicsQuestionVoteByArray($aTopicId,$sUserId);
|
||||
foreach ($data as $oTopicVote) {
|
||||
$aTopicsQuestionVote[$oTopicVote->getTopicId()]=$oTopicVote;
|
||||
}
|
||||
$this->Cache_Set($aTopicsQuestionVote, "topic_question_vote_{$sUserId}_id_{$s}", array("topic_question_vote_user_{$sUserId}"), 60*60*24*1);
|
||||
return $aTopicsQuestionVote;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* Добавляет факт голосования за топик-вопрос
|
||||
*
|
||||
|
@ -953,6 +1075,7 @@ class LsTopic extends Module {
|
|||
*/
|
||||
public function AddTopicQuestionVote(TopicEntity_TopicQuestionVote $oTopicQuestionVote) {
|
||||
$this->Cache_Delete("topic_question_vote_{$oTopicQuestionVote->getTopicId()}_{$oTopicQuestionVote->getVoterId()}");
|
||||
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("topic_question_vote_user_{$oTopicQuestionVote->getVoterId()}"));
|
||||
return $this->oMapperTopic->AddTopicQuestionVote($oTopicQuestionVote);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -116,6 +116,12 @@ class LsUser extends Module {
|
|||
* @param array $aUserId
|
||||
*/
|
||||
public function GetUsersByArrayId($aUserId) {
|
||||
if (!$aUserId) {
|
||||
return array();
|
||||
}
|
||||
if (1) {
|
||||
return $this->GetUsersByArrayIdSolid($aUserId);
|
||||
}
|
||||
if (!is_array($aUserId)) {
|
||||
$aUserId=array($aUserId);
|
||||
}
|
||||
|
@ -126,7 +132,7 @@ class LsUser extends Module {
|
|||
* Делаем мульти-запрос к кешу
|
||||
*/
|
||||
$aCacheKeys=func_build_cache_keys($aUserId,'user_');
|
||||
if (0 and false !== ($data = $this->Cache_Get($aCacheKeys))) {
|
||||
if (false !== ($data = $this->Cache_Get($aCacheKeys))) {
|
||||
/**
|
||||
* проверяем что досталось из кеша
|
||||
*/
|
||||
|
@ -152,7 +158,7 @@ class LsUser extends Module {
|
|||
* Добавляем к результату и сохраняем в кеш
|
||||
*/
|
||||
$aUsers[$oUser->getId()]=$oUser;
|
||||
//$this->Cache_Set($oUser, "user_{$oUser->getId()}", array(), 60*60*24*4);
|
||||
$this->Cache_Set($oUser, "user_{$oUser->getId()}", array(), 60*60*24*4);
|
||||
$aUserIdNeedStore=array_diff($aUserIdNeedStore,array($oUser->getId()));
|
||||
}
|
||||
}
|
||||
|
@ -168,12 +174,35 @@ class LsUser extends Module {
|
|||
$aUsers=func_array_sort_by_keys($aUsers,$aUserId);
|
||||
return $aUsers;
|
||||
}
|
||||
public function GetUsersByArrayIdSolid($aUserId) {
|
||||
if (!is_array($aUserId)) {
|
||||
$aUserId=array($aUserId);
|
||||
}
|
||||
$aUserId=array_unique($aUserId);
|
||||
$aUsers=array();
|
||||
$s=join(',',$aUserId);
|
||||
if (false === ($data = $this->Cache_Get("user_id_{$s}"))) {
|
||||
$data = $this->oMapper->GetUsersByArrayId($aUserId);
|
||||
foreach ($data as $oUser) {
|
||||
$aUsers[$oUser->getId()]=$oUser;
|
||||
}
|
||||
$this->Cache_Set($aUsers, "user_id_{$s}", array("user_update"), 60*60*24*1);
|
||||
return $aUsers;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* Список сессий юзеров по ID
|
||||
*
|
||||
* @param array $aUserId
|
||||
*/
|
||||
public function GetSessionsByArrayId($aUserId) {
|
||||
if (!$aUserId) {
|
||||
return array();
|
||||
}
|
||||
if (1) {
|
||||
return $this->GetSessionsByArrayIdSolid($aUserId);
|
||||
}
|
||||
if (!is_array($aUserId)) {
|
||||
$aUserId=array($aUserId);
|
||||
}
|
||||
|
@ -226,6 +255,29 @@ class LsUser extends Module {
|
|||
$aSessions=func_array_sort_by_keys($aSessions,$aUserId);
|
||||
return $aSessions;
|
||||
}
|
||||
/**
|
||||
* Получить список сессий по списку айдишников, но используя единый кеш
|
||||
*
|
||||
* @param unknown_type $aUserId
|
||||
* @return unknown
|
||||
*/
|
||||
public function GetSessionsByArrayIdSolid($aUserId) {
|
||||
if (!is_array($aUserId)) {
|
||||
$aUserId=array($aUserId);
|
||||
}
|
||||
$aUserId=array_unique($aUserId);
|
||||
$aSessions=array();
|
||||
$s=join(',',$aUserId);
|
||||
if (false === ($data = $this->Cache_Get("user_session_id_{$s}"))) {
|
||||
$data = $this->oMapper->GetSessionsByArrayId($aUserId);
|
||||
foreach ($data as $oSession) {
|
||||
$aSessions[$oSession->getUserId()]=$oSession;
|
||||
}
|
||||
$this->Cache_Set($aSessions, "user_session_id_{$s}", array("user_session_update"), 60*60*24*1);
|
||||
return $aSessions;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* Получает сессию юзера
|
||||
*
|
||||
|
@ -581,6 +633,12 @@ class LsUser extends Module {
|
|||
* @param unknown_type $aUserId
|
||||
*/
|
||||
public function GetFriendsByArray($aUserId,$sUserId) {
|
||||
if (!$aUserId) {
|
||||
return array();
|
||||
}
|
||||
if (1) {
|
||||
return $this->GetFriendsByArraySolid($aUserId,$sUserId);
|
||||
}
|
||||
if (!is_array($aUserId)) {
|
||||
$aUserId=array($aUserId);
|
||||
}
|
||||
|
@ -633,6 +691,30 @@ class LsUser extends Module {
|
|||
$aFriends=func_array_sort_by_keys($aFriends,$aUserId);
|
||||
return $aFriends;
|
||||
}
|
||||
/**
|
||||
* Получить список отношений с френдами по списку айдишников, но используя единый кеш
|
||||
*
|
||||
* @param unknown_type $aUserId
|
||||
* @param unknown_type $sUserId
|
||||
* @return unknown
|
||||
*/
|
||||
public function GetFriendsByArraySolid($aUserId,$sUserId) {
|
||||
if (!is_array($aUserId)) {
|
||||
$aUserId=array($aUserId);
|
||||
}
|
||||
$aUserId=array_unique($aUserId);
|
||||
$aFriends=array();
|
||||
$s=join(',',$aUserId);
|
||||
if (false === ($data = $this->Cache_Get("user_friend_{$sUserId}_id_{$s}"))) {
|
||||
$data = $this->oMapper->GetFriendsByArrayId($aUserId,$sUserId);
|
||||
foreach ($data as $oFriend) {
|
||||
$aFriends[$oFriend->getFriendId()]=$oFriend;
|
||||
}
|
||||
$this->Cache_Set($aFriends, "user_friend_{$sUserId}_id_{$s}", array("friend_change_user_{$sUserId}"), 60*60*24*1);
|
||||
return $aFriends;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* Получаем привязку друга к юзеру(есть ли у юзера данный друг)
|
||||
*
|
||||
|
|
|
@ -42,6 +42,7 @@ class LsVote extends Module {
|
|||
public function AddVote(VoteEntity_Vote $oVote) {
|
||||
if ($this->oMapper->AddVote($oVote)) {
|
||||
$this->Cache_Delete("vote_{$oVote->getTargetType()}_{$oVote->getTargetId()}_{$oVote->getVoterId()}");
|
||||
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("vote_update_{$oVote->getTargetType()}_{$oVote->getVoterId()}"));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -70,6 +71,12 @@ class LsVote extends Module {
|
|||
* @param unknown_type $sTargetType
|
||||
*/
|
||||
public function GetVoteByArray($aTargetId,$sTargetType,$sUserId) {
|
||||
if (!$aTargetId) {
|
||||
return array();
|
||||
}
|
||||
if (1) {
|
||||
return $this->GetVoteByArraySolid($aTargetId,$sTargetType,$sUserId);
|
||||
}
|
||||
if (!is_array($aTargetId)) {
|
||||
$aTargetId=array($aTargetId);
|
||||
}
|
||||
|
@ -80,7 +87,7 @@ class LsVote extends Module {
|
|||
* Делаем мульти-запрос к кешу
|
||||
*/
|
||||
$aCacheKeys=func_build_cache_keys($aTargetId,"vote_{$sTargetType}_",'_'.$sUserId);
|
||||
if (0 and false !== ($data = $this->Cache_Get($aCacheKeys))) {
|
||||
if (false !== ($data = $this->Cache_Get($aCacheKeys))) {
|
||||
/**
|
||||
* проверяем что досталось из кеша
|
||||
*/
|
||||
|
@ -106,7 +113,7 @@ class LsVote extends Module {
|
|||
* Добавляем к результату и сохраняем в кеш
|
||||
*/
|
||||
$aVote[$oVote->getTargetId()]=$oVote;
|
||||
//$this->Cache_Set($oVote, "vote_{$oVote->getTargetType()}_{$oVote->getTargetId()}_{$oVote->getVoterId()}", array(), 60*60*24*7);
|
||||
$this->Cache_Set($oVote, "vote_{$oVote->getTargetType()}_{$oVote->getTargetId()}_{$oVote->getVoterId()}", array(), 60*60*24*7);
|
||||
$aIdNeedStore=array_diff($aIdNeedStore,array($oVote->getTargetId()));
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +121,7 @@ class LsVote extends Module {
|
|||
* Сохраняем в кеш запросы не вернувшие результата
|
||||
*/
|
||||
foreach ($aIdNeedStore as $sId) {
|
||||
//$this->Cache_Set(null, "vote_{$sTargetType}_{$sId}_{$sUserId}", array(), 60*60*24*7);
|
||||
$this->Cache_Set(null, "vote_{$sTargetType}_{$sId}_{$sUserId}", array(), 60*60*24*7);
|
||||
}
|
||||
/**
|
||||
* Сортируем результат согласно входящему массиву
|
||||
|
@ -122,6 +129,30 @@ class LsVote extends Module {
|
|||
$aVote=func_array_sort_by_keys($aVote,$aTargetId);
|
||||
return $aVote;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить список голосований по списку айдишников, но используя единый кеш
|
||||
*
|
||||
* @param unknown_type $aTargetId
|
||||
* @param unknown_type $sTargetType
|
||||
* @param unknown_type $sUserId
|
||||
* @return unknown
|
||||
*/
|
||||
public function GetVoteByArraySolid($aTargetId,$sTargetType,$sUserId) {
|
||||
if (!is_array($aTargetId)) {
|
||||
$aTargetId=array($aTargetId);
|
||||
}
|
||||
$aTargetId=array_unique($aTargetId);
|
||||
$aVote=array();
|
||||
$s=join(',',$aTargetId);
|
||||
if (false === ($data = $this->Cache_Get("vote_{$sTargetType}_{$sUserId}_id_{$s}"))) {
|
||||
$data = $this->oMapper->GetVoteByArray($aTargetId,$sTargetType,$sUserId);
|
||||
foreach ($data as $oVote) {
|
||||
$aVote[$oVote->getTargetId()]=$oVote;
|
||||
}
|
||||
$this->Cache_Set($aVote, "vote_{$sTargetType}_{$sUserId}_id_{$s}", array("vote_update_{$sTargetType}_{$sUserId}"), 60*60*24*1);
|
||||
return $aVote;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue