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
 /**
  * Clear cache top player
  * @param array $params
  * @return array
  * @author QuangTM
  */
 public function clearCacheTopPlayer($params)
 {
     // Get params
     $seasonID = $params['seasonID'];
     try {
         $keyCache = Thethao_Global::makeCacheKey(Thethao_Model_PlayerChampion::PLAYER_CHAMPION_BY_SEASON, $seasonID);
         Thethao_Global::deleteMemcache(array($keyCache));
     } catch (Exception $ex) {
         Thethao_Global::sendLog($ex);
     }
     return;
 }
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;
 }
 /**
  * @author      : HungNT
  * call job clear cache keybox fe
  * @todo        : clearCacheKeybox
  * @param type $arrParams
  */
 public function clearCacheKeybox($params)
 {
     // Delete cache
     $keyCache = Thethao_Global::makeCacheKey($params['key_id']);
     if (!$keyCache) {
         $keyCache = $params['key_id'];
     }
     Thethao_Global::deleteMemcache(array($keyCache));
     // Get player model
     $model = new Thethao_Model_Block();
     $arrReturn = $model->getKeyBox($params);
     //init news instance
     $caching = Thethao_Model_Caching::getInstance();
     $caching->clearCacheFile();
     //return
     return $arrReturn;
 }
Esempio n. 5
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;
 }