Esempio n. 1
0
 public function updateMatchByFan($params)
 {
     // Default response
     $response = NULL;
     try {
         // Get config application
         $config = Thethao_Global::getApplicationIni();
         // Get team_match object
         $matchMysqlObj = $this->factory('Match', $config['database']['default']['adapter']);
         // Get match infos fan
         $arrMatchFan = $matchMysqlObj->getFanByMatch($params['matchId']);
         //Update
         if (isset($arrMatchFan['match_id']) && is_numeric($arrMatchFan['match_id']) && $arrMatchFan['match_id'] > 0) {
             if ($params['likeType'] == 0) {
                 $score = -1;
             } else {
                 $score = 1;
             }
             // Params update
             $paramUpdate = array('matchId' => $params['matchId'], 'fanteam_1' => $params['fanLikeTeam'] == 1 ? $arrMatchFan['fan_team1'] + $score : $arrMatchFan['fan_team1'], 'fanteam_2' => $params['fanLikeTeam'] == 2 ? $arrMatchFan['fan_team2'] + $score : $arrMatchFan['fan_team2']);
             if ($matchMysqlObj->updateMatchByFan($paramUpdate)) {
                 $keyCache = Thethao_Global::makeCacheKey(Thethao_Model_Match::EURO2012_MATCH_LIKE, array($params['matchId']));
                 Thethao_Global::deleteMemcache(array($keyCache));
             }
             //end if
         }
         //end if
     } catch (Exception $ex) {
         Thethao_Global::sendLog($ex);
     }
     return $response;
 }
Esempio n. 2
0
 /**
  * call job clear cache file
  * @param array $articleDetail
  * @param string $action
  * @return boolean|array
  */
 public function clearCacheFile($action = 'file')
 {
     try {
         //set secret key
         $secret_key = 'e146b700f216df93a2dd5ca6e26c7c2c';
         //get app config
         $config = Thethao_Global::getApplicationIni();
         $arrServer = $config['ipserver']['thethao'];
         $host = $config['view']['host'];
         $headers = array("Host: " . $host);
         //init curl
         $arrCurl = array();
         //$arrServer = array('180.148.142.92', '180.148.142.171');
         foreach ($arrServer as $i => $server) {
             $arrCurl[$i] = curl_init();
             curl_setopt($arrCurl[$i], CURLOPT_HTTPHEADER, $headers);
             curl_setopt($arrCurl[$i], CURLOPT_TIMEOUT, 5);
             curl_setopt($arrCurl[$i], CURLOPT_RETURNTRANSFER, true);
             curl_setopt($arrCurl[$i], CURLOPT_URL, "http://{$server}/clear_file.php?action={$action}&sck={$secret_key}");
         }
         //create the multiple cURL handle
         $mh = curl_multi_init();
         foreach ($arrCurl as $ch) {
             curl_multi_add_handle($mh, $ch);
         }
         //execute the handles
         $running = null;
         do {
             curl_multi_exec($mh, $running);
         } while ($running > 0);
         // get content and remove handles to debug if fall
         /*foreach($arrCurl as $id => $c) {
               $result[$id] = curl_multi_getcontent($c);
           }*/
         foreach ($arrCurl as $ch) {
             curl_multi_remove_handle($mh, $ch);
         }
         //close the handles
         curl_multi_close($mh);
         //var_dump( $result);
         return true;
     } catch (Exception $ex) {
         //log error
         Thethao_Global::sendLog($ex);
     }
     return false;
 }
Esempio n. 3
0
 /**
  * Get data from site Ngoisao and update to redis
  * @param array $params - array (article_id, original_url)
  * @return Boolean
  */
 public function updateShareUrl($params)
 {
     // Default response
     $response = NULL;
     try {
         $article_id = intval($params['article_id']);
         $article_url = $params['original_url'];
         //get config key
         $config = Thethao_Global::getApplicationIni();
         // Get redis instance
         $redisInstance = Thethao_Global::getRedis('article');
         //make key
         $keyCache = Thethao_Global::makeCacheKey($config['view']['keyReis']['ngoisao']);
         //set redis
         $response = $redisInstance->hSet($keyCache, $article_id, $article_url);
     } catch (Exception $ex) {
         Thethao_Global::sendLog($ex);
     }
     return $response;
 }
Esempio n. 4
0
 /**
  * delete related list news when delete article from BE editor
  * @param array $arrArticleDetail old detail article
  * @return array
  * @author PhuongTN
  * @todo thethao
  */
 public function deleteArticle($arrArticleDetail)
 {
     try {
         $arrResponse = array();
         //get app conf
         $config = Thethao_Global::getApplicationIni();
         //get list rule category
         $this->getArticleForJob($arrArticleDetail);
         //get news nosql instance
         $newsNosql = $this->factory('Article', $config['database']['nosql']['adapter']);
         //call deletea list
         $arrResponse['nosql_article'] = $newsNosql->deleteArticle($arrArticleDetail);
         //init model news
         $modelNews = Thethao_Model_News::getInstance();
         //precache rule 3 cho site seagames
         $param_rule3 = array('category_id' => SEA_GAMES, 'offset' => 0, 'limit' => 1);
         $arrResponse['rule3'] = $modelNews->getListArticleIdsByRule3($param_rule3);
     } catch (Exception $ex) {
         Thethao_Global::sendLog($ex);
     }
     //return data
     return $arrResponse;
 }
Esempio n. 5
0
 /**
  * Get job client
  * @param string $strFarmName
  * @param string $zoneName
  * @return Fpt_Job_Client
  * @author LamTX
  */
 public static function getJobClientInstance($strFarmName = 'sport', $zoneName = ZONE_ENV)
 {
     try {
         //Get caching instance
         if (!isset(self::$_jobClient[$strFarmName])) {
             //get array conf
             $arrConf = Thethao_Global::getApplicationIni();
             //get job client instance
             self::$_jobClient[$strFarmName] = Fpt_Job_Client::factory($arrConf['job'][$zoneName][$strFarmName]['adapter'], $arrConf['job'][$zoneName][$strFarmName]);
             unset($arrConf);
         }
         //Return jobclient
         return self::$_jobClient[$strFarmName];
     } catch (Exception $ex) {
         //log error
         Thethao_Global::sendLog($ex);
         return false;
     }
 }
Esempio n. 6
0
 public function __construct()
 {
     $config = Thethao_Global::getApplicationIni();
     $this->_image_url = $config['view']['images'];
 }
Esempio n. 7
0
 public function getListAward11($arrParams)
 {
     $arrReturn = false;
     $config = Thethao_Global::getApplicationIni();
     $nosql = $this->factory('News', $config['database']['nosql']['adapter']);
     if ($arrParams['isGearman'] == false) {
         $arrReturn = $nosql->getListAward($arrParams);
         //var_dump($arrReturn);
     }
     if (empty($arrReturn) || $arrReturn == false) {
         $config = Thethao_Global::getApplicationIni();
         //init mysql instance
         $newsMysql = $this->factory('News', $config['database']['default']['adapter']);
         //get db list
         $arrReturn = $newsMysql->getListAward($arrParams);
         $nosql->setListAward($arrParams, $arrReturn);
     }
     return $arrReturn;
 }
Esempio n. 8
0
 public function __construct()
 {
     $config = Thethao_Global::getApplicationIni();
     $this->iconmore = ' <img src="' . $config['view']['images'] . '/graphics/icon_lead_more.gif" />';
 }
Esempio n. 9
0
 /**
  * Get list players by team
  * @param int $teamId
  * @return array
  * @author ThuyNT
  */
 public function getListPlayersByTeam($teamId)
 {
     $memcacheInstance = Thethao_Global::getCache();
     $keyCache = vsprintf($this->_player_by_team, array($teamId));
     // Read from cache
     $arrListPlayers = $memcacheInstance->read($keyCache);
     // Miss cache
     if ($arrListPlayers === FALSE) {
         try {
             // Get application's configuation
             $config = Thethao_Global::getApplicationIni();
             // Get mysql object access player
             $playerMysqlObj = $this->factory('Player', $config['database']['default']['adapter']);
             // Get data from db
             $arrListPlayers = $playerMysqlObj->getListPlayersByTeam($teamId);
             if (!empty($arrListPlayers)) {
                 // Write to cache
                 $memcacheInstance->write($keyCache, $arrListPlayers);
                 Thethao_Global::writeMemcache($keyCache, $arrListPlayers);
             } else {
                 // Store into cache
                 $memcacheInstance->write($keyCache, -1);
                 Thethao_Global::writeMemcache($keyCache, -1);
             }
         } catch (Exception $ex) {
             Thethao_Global::sendlog($ex, 1);
         }
     } else {
         if ($arrListPlayers == -1) {
             $arrListPlayers = array();
         }
     }
     return $arrListPlayers;
 }
Esempio n. 10
0
 /**
  * Get list match ids by league
  * @param int $teamID
  * @param int $beginHappenDateTime
  * @param int $endHappenDateTime
  * @param boolean - asort array
  * @return array|boolean
  * @author ThuyNT
  */
 public function getMatchIDsByLeague($leagueID, $beginHappenDateTime = NULL, $endHappenDateTime = NULL, $rev = TRUE)
 {
     // Default result to return
     $result = FALSE;
     $flag = TRUE;
     try {
         // Get application config
         $config = Thethao_Global::getApplicationIni();
         //get object redis
         $matchNosqlInstance = $this->factory('Match', $config['database']['nosql']['adapter']);
         // Read from redis first
         $result = $matchNosqlInstance->getListMatchesByHappenTime($leagueID, $beginHappenDateTime, $endHappenDateTime);
         // If miss cache redis => read from DB
         if (empty($result['data']) && FROM_JOB == 1) {
             //get mysql instance
             $matchMysqlInstance = $this->factory('Match', $config['database']['default']['adapter']);
             // Read data from MySQL
             $result = $matchMysqlInstance->getListMatchesByHappenTime($beginHappenDateTime, $endHappenDateTime, $leagueID, $gmt = 0, $flag);
             //check to set redis
             if (!empty($result)) {
                 $matchNosqlInstance->setMatchIDsByLeague($leagueID, $result);
             }
             $intTotal = count($result);
             $arrTest = array_values($result);
             if ($beginHappenDateTime) {
                 for ($i = $intTotal - 1; $i > 0; $i--) {
                     if ($arrTest[$i] >= $beginHappenDateTime) {
                         $result = array_slice($result, 0, $i + 1, true);
                         $i = 0;
                     }
                 }
             }
             if ($endHappenDateTime) {
                 for ($i = 0; $i < $intTotal; $i++) {
                     if ($arrTest[$i] <= $endHappenDateTime) {
                         $result = array_slice($result, $i, NULL, true);
                         $i = $intTotal;
                     }
                 }
             }
         } else {
             $result = $result['data'];
         }
         if (!$rev && !empty($result)) {
             asort($result);
         }
     } catch (Exception $ex) {
         Fpt_Data_Model::sendLog($ex);
     }
     return $result;
 }
Esempio n. 11
0
 /**
  * @author      : VinhNT
  * @name        : ajaxsendmailAction
  * @copyright   : FPT Online
  * @todo        : ajaxsendmail Action
  * @return      : array('error' => 0, 'message' => '', 'body' => '')
  */
 public function ajaxsendmailAction()
 {
     //Disable layout
     $this->_helper->layout->disableLayout(true);
     //Set no render view
     $this->_helper->viewRenderer->setNoRender(true);
     //default return
     $response = array('error' => 0, 'message' => '');
     /* -----------------------------------------------------------------
         Get param sent to job send mail
        */
     try {
         $arrParams = $this->_request->getPost();
         //Trim captcha id
         $arrCaptcha['id'] = trim($arrParams['captchaID']);
         $arrCaptcha['input'] = trim($arrParams['txtCode']);
         // Creating a Zend_Captcha_Image instance
         $captcha = new Zend_Captcha_Image();
         // would be key/value array: id => captcha ID, input => captcha value
         if ($captcha->isValid($arrCaptcha)) {
             // Include config send mail
             include APPLICATION_PATH . '/configs/mail.php';
             //Check config sender
             if (is_array($configsender) && !empty($configsender)) {
                 // Get Url to send
                 $url_send = $arrParams['url'];
                 $url_send = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($url_send))));
                 $url_send = str_replace('http://thethao.vnexpress.net', 'http://seagames.vnexpress.net', $url_send);
                 // Get name of the sender
                 $sender_name = $arrParams['sender_name'];
                 $sender_name = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($sender_name))));
                 if (empty($sender_name)) {
                     $response['error'] = 1;
                     $response['message'] = 'Xin hãy nhập họ tên người gửi.';
                     echo Zend_Json::encode($response);
                     exit;
                 }
                 // Get user email
                 $email_user = $arrParams['email_user'];
                 $email_user = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($email_user))));
                 //Check email user
                 if (empty($email_user)) {
                     $response['error'] = 1;
                     $response['message'] = 'Xin hãy nhập email người gửi.';
                     echo Zend_Json::encode($response);
                     exit;
                 }
                 // Get title of send mail
                 $title_email = urldecode($arrParams['title_email']);
                 $title_email = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($title_email))));
                 //Set parrams email sender
                 $sender_email = $configsender['message']['email'];
                 // Get email of the reciever
                 $reciever_mail = $arrParams['receiver_mail'];
                 $reciever_mail = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($reciever_mail))));
                 //Check reciever mail
                 if (empty($reciever_mail)) {
                     $response['error'] = 1;
                     $response['message'] = 'Xin hãy nhập email người nhận.';
                     echo Zend_Json::encode($response);
                     exit;
                 }
                 // Get message mail
                 $message_mail = $arrParams['message_mail'];
                 $message_mail = trim(strip_tags($message_mail));
                 //Get body message
                 $body_message = '<strong>' . $sender_name . '(' . $email_user . ')</strong><br/>Đã gửi cho bạn bài báo tại link: <a href="' . $url_send . '" title="' . $title_email . '">' . $url_send . '</a>';
                 //Check message mail
                 if (!empty($message_mail)) {
                     $body_message .= '<br/>Với nội dung: </br>' . $message_mail;
                 }
                 $body_message .= '<hr><br/>Email này được gửi bằng tiện ích "Gửi cho bạn bè" của <b>SEAGames.VnExpress.net<b>';
                 //Get array mail
                 $arrEmail = explode(';', $reciever_mail);
                 $arrEmailReciever = array();
                 //Check array email
                 if (!empty($arrEmail)) {
                     foreach ($arrEmail as $email) {
                         $email = trim($email);
                         //If email is NOT valid
                         if (@(!eregi("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)+\$", (string) $email))) {
                             //if (@!Fpt_Valid::isEmail($email))
                             continue;
                         }
                         //Put data to arrReciever
                         $arrEmailReciever[] = array('email' => $email, 'alias' => $email);
                     }
                     if (!empty($arrEmailReciever)) {
                         //push job call send mail
                         $jobParams = array('class' => 'Job_Thethao_JobMessage', 'function' => 'sendMail', 'args' => array('sender' => $sender_email, 'name' => 'VNE SEA Games', 'reciever' => $arrEmailReciever, 'subject' => $title_email, 'body' => $body_message));
                         //get application config
                         $config = Thethao_Global::getApplicationIni();
                         //To array
                         $jobConfiguration = $config['job']['task']['sport']['send_mail'];
                         //get job send mail instance
                         $jobClient = Thethao_Global::getJobClientInstance('sport');
                         //Register job
                         $result = $jobClient->doBackgroundTask($jobConfiguration, $jobParams);
                         if (!$result) {
                             $response['error'] = 1;
                             $response['message'] = 'Không gửi được email. Xin vui lòng thử lại sau.';
                             echo Zend_Json::encode($response);
                             exit;
                         } else {
                             $response['error'] = 0;
                             $response['message'] = 'Gửi email thành công.';
                             echo Zend_Json::encode($response);
                             exit;
                         }
                     } else {
                         $response['error'] = 1;
                         $response['message'] = 'Email gửi đến không hợp lệ';
                         echo Zend_Json::encode($response);
                         exit;
                     }
                 }
             } else {
                 $response['error'] = 1;
                 $response['message'] = 'Empty recipient.';
                 echo Zend_Json::encode($response);
                 exit;
             }
         } else {
             $response['error'] = 2;
             $response['message'] = 'Mã xác nhận không đúng.';
             echo Zend_Json::encode($response);
             exit;
         }
     } catch (Exception $ex) {
         // Log error
         Thethao_Global::sendLog($ex);
     }
     echo Zend_Json::encode($response);
     exit;
 }
Esempio n. 12
0
 /**
  * Get list league by group
  * @param int $group
  * @return array
  */
 public function getListLeagueByGroup($group)
 {
     $memcacheInstance = Thethao_Global::getCache();
     $keyCache = vsprintf($this->_league_by_group_list, array($group));
     // Read cache
     $listLeagues = $memcacheInstance->read($keyCache);
     // Miss cache
     if ($listLeagues === FALSE) {
         try {
             $config = Thethao_Global::getApplicationIni();
             // Get db teamseason instance
             $leagueObj = $this->factory('Football', $config['database']['default']['adapter']);
             // Get data from db
             $listLeagues = $leagueObj->getListLeagueByGroup($group);
             // Write to cache
             $memcacheInstance->write($keyCache, $listLeagues);
             Thethao_Global::writeMemcache($keyCache, $listLeagues);
         } catch (Exception $ex) {
             Thethao_Global::sendlog($ex);
         }
     }
     return $listLeagues;
 }
Esempio n. 13
0
$opts = new Zend_Console_Getopt(array('v-i' => 'verbose option'));
//Get info console
$verbose = $opts->getOption('v');
//load application env by unix var
define('APP_ENV', isset($_SERVER['APPLICATION_ENV']) ? $_SERVER['APPLICATION_ENV'] : 'development');
define('ZONE_ENV', isset($_SERVER['ZONE_ENV']) ? $_SERVER['ZONE_ENV'] : 'hn');
$_SERVER['SERVER_MASTER'] = 'thethao';
//Print information envirement
if ($verbose) {
    echo "DOCUMENT_ROOT : " . DOCUMENT_ROOT . "\n";
    echo "APPLICATION_PATH : " . APPLICATION_PATH . "\n";
    echo "LIBS_PATH : " . LIBS_PATH . "\n";
    echo "ENVIRONMENT : " . APP_ENV . "\n";
}
//Get Configuration
$configuration = Thethao_Global::getApplicationIni();
//Load defined configuration
require_once APPLICATION_PATH . '/configs/defined.php';
//Set worker
$jobConfiguration = $configuration['job'][ZONE_ENV]['sport'];
$worker = Fpt_JobWorker::getInstance($jobConfiguration);
//Add function to worker
$worker->addFunction($jobConfiguration[$jobConfiguration['adapter']]['function']['write_cache'], 'reduceFn');
$worker->addFunction($jobConfiguration[$jobConfiguration['adapter']]['function']['init_data_team_match'], 'reduceFn');
$worker->addFunction($jobConfiguration[$jobConfiguration['adapter']]['function']['init_data_team_match_by_teamid'], 'reduceFn');
$worker->addFunction($jobConfiguration[$jobConfiguration['adapter']]['function']['init_data_league_season_by_teamid'], 'reduceFn');
//Run worker
$return = $worker->run();
//Print result
if ($verbose) {
    echo "Result : {$return}\n";
Esempio n. 14
0
 /**
  * Get full category include all sub category
  * @return array
  * @author LamTX
  */
 public function getFullCategoryByParentId($preCache = false)
 {
     if ($this->_cate == null) {
         $intCategoryID = SITE_ID;
         // Get instance memcache
         $memcacheInstance = Thethao_Global::getCache();
         $keyCache = vsprintf($this->_key_cache, array($intCategoryID));
         // Get full category from Memcache
         $arrMenuCate = $memcacheInstance->read($keyCache);
         //$arrFullCatInfo = array();
         // Data not in cache
         if ($preCache || empty($arrMenuCate['menu']) && empty($arrMenuCate['cate'])) {
             // Get application config
             $config = Thethao_Global::getApplicationIni();
             // Get instance mysql
             $cateMysql = $this->factory('Category', $config['database']['default']['adapter']);
             $arrMenuCate = array('menu' => array(), 'cate' => array());
             // Get cate in DB
             $arrFullCatInfo = $cateMysql->getFullCategoryByParentId($intCategoryID);
             if (!empty($arrFullCatInfo)) {
                 $arrTemp = array();
                 foreach ($arrFullCatInfo as $detail) {
                     $detail['child'] = $detail['child_recursive'] = array();
                     //update cate share_url
                     if ($detail['parent_id'] == SITE_ID) {
                         switch ($detail['category_id']) {
                             case CATE_ID_VIDEO:
                             case CATE_ID_PHOTO:
                             case CATE_ID_FIXTURE:
                                 $detail['link'] = '/' . $detail['catecode'];
                                 break;
                             case SITE_ID:
                                 $detail['link'] = '/';
                                 break;
                             default:
                                 $detail['link'] = '/tin-tuc/' . $detail['catecode'];
                                 break;
                         }
                     } else {
                         //check world cup
                         if ($detail['parent_id'] == WORLD_CUP || $detail['parent_id'] == SEA_GAMES) {
                             $detail['link'] = '/' . $detail['catecode'];
                         } else {
                             $detail['link'] = $arrTemp[$detail['parent_id']]['link'] . '/' . $detail['catecode'];
                         }
                     }
                     //end if
                     //explode parent => array
                     $detail['full_parent'] = $detail['full_parent_original'] = explode(',', $detail['full_parent']);
                     //remove site_id
                     unset($detail['full_parent'][0]);
                     //pre order key
                     $detail['full_parent'] = array_values($detail['full_parent']);
                     //assign array temp
                     $arrTemp[$detail['category_id']] = $detail;
                     //update share_url + parent to original array
                     $arrFullCatInfo[$detail['category_id']] = $detail;
                     //if this cate have parent
                     if (!empty($arrTemp[$detail['category_id']]['full_parent_original'])) {
                         foreach ($arrTemp[$detail['category_id']]['full_parent_original'] as $intParentId) {
                             //if not SITE_ID (cate_id=parent_id)
                             if ($intParentId != $detail['category_id']) {
                                 //update child
                                 $arrTemp[$intParentId]['child_recursive'][] = $detail['category_id'];
                                 $arrFullCatInfo[$intParentId]['child_recursive'][] = $detail['category_id'];
                             }
                             //end if
                         }
                         //end foreach
                         //update current cate child list
                         if ($intParentId != $detail['category_id']) {
                             $arrTemp[$detail['parent_id']]['child'][$detail['category_id']] = $detail;
                             $arrFullCatInfo[$detail['parent_id']]['child'][] = $detail['category_id'];
                         }
                         //end if
                     }
                     //end if
                 }
                 //end foreach
                 //format output
                 $arrMenuCate['menu'] = array(SITE_ID => $arrTemp[SITE_ID]);
                 $arrMenuCate['cate'] = $arrFullCatInfo;
                 //wriet memcache
                 $memcacheInstance->write($keyCache, $arrMenuCate);
                 //check from job to write memcached hcm
                 if ($preCache) {
                     Thethao_Global::writeMemcache($keyCache, $arrMenuCate, 'all');
                 }
                 //end if
             }
             //end if
         }
         //end if
         $this->_menu = $arrMenuCate['menu'];
         $this->_cate = $arrMenuCate['cate'];
     }
     //end if
     return $this->_cate;
 }
Esempio n. 15
0
 /**
  * Insert tennis match into redis key
  * @param array $matchInfo
  * @return boolean
  * @author QuangTM
  */
 public function insertTennisMatchIntoRedis($matchInfo)
 {
     // Get application config
     $config = Thethao_Global::getApplicationIni();
     // Get obj access redis key team_match
     $tennisRedisObj = $this->factory('Tennis', $config['database']['nosql']['adapter']);
     // Insert tennis info into redis
     return $tennisRedisObj->insertTennisMatches($matchInfo);
 }
Esempio n. 16
0
 /**
  * Function get data from table keybox by key_box_id
  * @param array $params
  * @return array data
  */
 public function getKeyBox($params)
 {
     try {
         // Build key cache
         $keyCache = Thethao_Global::makeCacheKey($params['key_id']);
         if (!$keyCache) {
             $keyCache = $params['key_id'];
         }
         // Get instance memcache
         $memcacheInstance = Thethao_Global::getCache();
         // Read hot match in memcache
         $arrReturn = $memcacheInstance->read($keyCache);
         //check cache
         if ($arrReturn === FALSE) {
             //get app config
             $config = Thethao_Global::getApplicationIni();
             //get mysql instance
             $mysqlInstance = $this->factory('Block', $config['database']['default']['adapter']);
             // Get data in DB
             $arrReturn = $mysqlInstance->getKeyBox('"' . $params['key_id'] . '"');
             //Decode Json for write memcache
             $arrReturn = Zend_Json::decode($arrReturn[$params['key_id']]);
             if (!empty($arrReturn)) {
                 // Store into cache
                 $memcacheInstance->write($keyCache, $arrReturn);
                 Thethao_Global::writeMemcache($keyCache, $arrReturn);
             } else {
                 // Store into cache
                 $memcacheInstance->write($keyCache, -1);
                 Thethao_Global::writeMemcache($keyCache, -1);
             }
         } else {
             if ($arrReturn == -1) {
                 $arrReturn = array();
             }
         }
     } catch (Exception $ex) {
         //log error
         Thethao_Global::sendLog($ex);
     }
     return $arrReturn;
 }