Authored by 郝肖肖

通过 zookeeper 客服开关

@@ -79,7 +79,7 @@ class AbstractAction extends Controller_Abstract @@ -79,7 +79,7 @@ class AbstractAction extends Controller_Abstract
79 79
80 //客服配置 80 //客服配置
81 protected function getCustomerServiceSwitch() { 81 protected function getCustomerServiceSwitch() {
82 - return $this->_useSession && empty($this->getCache('customerServiceSwitch')) ? 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409' : '/service/client'; 82 + return $this->_useSession && empty($this->getCacheBy('zookeeper:/pc/clientService/new')) ? 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409' : '/service/client';
83 } 83 }
84 /** 84 /**
85 * 封装一下获取get参数 85 * 封装一下获取get参数
@@ -95,7 +95,7 @@ class WebAction extends Controller_Abstract @@ -95,7 +95,7 @@ class WebAction extends Controller_Abstract
95 95
96 //客服配置 96 //客服配置
97 protected function getCustomerServiceSwitch() { 97 protected function getCustomerServiceSwitch() {
98 - return $this->_useSession && empty($this->getCache('customerServiceSwitch')) ? 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409' : '/service/client'; 98 + return $this->_useSession && empty($this->getCacheBy('zookeeper:/pc/clientService/new')) ? 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409' : '/service/client';
99 } 99 }
100 100
101 /** 101 /**
@@ -347,6 +347,22 @@ class WebAction extends Controller_Abstract @@ -347,6 +347,22 @@ class WebAction extends Controller_Abstract
347 } 347 }
348 348
349 /** 349 /**
  350 + * 直接查询缓存,不对key做任何处理<php与node cache对接>
  351 + *
  352 + * @param string $key 键名
  353 + * @param bool $isMaster 控制是到主服务器取,还是到从服务器取缓存
  354 + * @return mixed
  355 + */
  356 + protected function getCacheBy($key, $isMaster = true)
  357 + {
  358 + if ($isMaster) {
  359 + return Cache::getBy($key, 'master');
  360 + } else {
  361 + return Cache::getBy($key, 'slave');
  362 + }
  363 + }
  364 +
  365 + /**
350 * 设置Session 366 * 设置Session
351 * 367 *
352 * @param string $name 名称 368 * @param string $name 名称
@@ -262,6 +262,18 @@ class ToolsController extends WebAction @@ -262,6 +262,18 @@ class ToolsController extends WebAction
262 262
263 var_dump(Cache::get('customerServiceSwitch')); 263 var_dump(Cache::get('customerServiceSwitch'));
264 } 264 }
  265 +
  266 + public function customerZllkeeperAction()
  267 + {
  268 + echo 'cache:get(zookeeper:/pc/clientService/new) ';
  269 + var_dump(Cache::get('zookeeper:/pc/clientService/new'));
  270 +
  271 + echo 'cache:getBy(zookeeper:/pc/clientService/new) ';
  272 + var_dump(Cache::getBy('zookeeper:/pc/clientService/new'));
  273 +
  274 + echo 'cache:getBy(zookeeper:/wap/clientService/new) ';
  275 + var_dump(Cache::getBy('zookeeper:/wap/clientService/new'));
  276 + }
265 } 277 }
266 278
267 ?> 279 ?>
@@ -45,7 +45,7 @@ class UserModel @@ -45,7 +45,7 @@ class UserModel
45 } 45 }
46 46
47 public static function getCustomerServiceSwitch() { 47 public static function getCustomerServiceSwitch() {
48 - return USE_CACHE && empty(Cache::get('customerServiceSwitch')) ? 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409' : '/service/client'; 48 + return USE_CACHE && empty(Cache::getBy('zookeeper:/pc/clientService/new')) ? 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409' : '/service/client';
49 } 49 }
50 /** 50 /**
51 * 个人中心-左侧导航 51 * 个人中心-左侧导航