Exemplo n.º 1
0
 /**
  * 获取campaign
  * @param int $campaignId
  * @return array
  */
 static function getById($campaignId)
 {
     $redis = RedisFactory::open()->connect($campaignId);
     $key = sprintf(self::$REDIS_KEYS['getById'], $campaignId);
     $result = $redis->get($key)->getResult();
     if ($result === false) {
         // 初始化
         $db = DatabaseFactory::open();
         $result = $db->createCommand("SELECT * FROM g_campaign WHERE id=:id")->findFirst(array(':id' => $campaignId));
         if (empty($result)) {
             $result = array();
         }
         $redis->set($key, $result);
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * 获取redis
  * @return IRedis
  */
 static function getRedis()
 {
     return RedisFactory::open(self::REDIS_CONFIG);
 }