edit shut memcache read
Showing
4 changed files
with
39 additions
and
6 deletions
@@ -165,7 +165,7 @@ class Yohobuy | @@ -165,7 +165,7 @@ class Yohobuy | ||
165 | $url = self::httpBuildQuery($url, $data); | 165 | $url = self::httpBuildQuery($url, $data); |
166 | } //echo $url; | 166 | } //echo $url; |
167 | 167 | ||
168 | - UdpLog::debug('get api', $url); | 168 | + UdpLog::debug('get shut api', $url); |
169 | 169 | ||
170 | /* 开启缓存的情况 */ | 170 | /* 开启缓存的情况 */ |
171 | if ($cache && USE_CACHE) { | 171 | if ($cache && USE_CACHE) { |
@@ -243,6 +243,8 @@ class Yohobuy | @@ -243,6 +243,8 @@ class Yohobuy | ||
243 | if (!empty($userAgent)) { | 243 | if (!empty($userAgent)) { |
244 | curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); | 244 | curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); |
245 | } | 245 | } |
246 | + | ||
247 | + UdpLog::debug('call api: ', $url); | ||
246 | $result = curl_exec($ch); | 248 | $result = curl_exec($ch); |
247 | 249 | ||
248 | $httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE); | 250 | $httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE); |
@@ -670,8 +672,11 @@ class Yohobuy | @@ -670,8 +672,11 @@ class Yohobuy | ||
670 | return false; | 672 | return false; |
671 | } | 673 | } |
672 | 674 | ||
673 | - $interfaceShunt = Cache::get('INTERFACE_SHUT_KEY', 'master'); | ||
674 | 675 | ||
676 | + UdpLog::debug('read memcache'); | ||
677 | + $interfaceShunt = Cache::getBy('INTERFACE_SHUT_KEY', 'master'); | ||
678 | + | ||
679 | + UdpLog::debug('read memcahe: ', $interfaceShunt); | ||
675 | if (empty($interfaceShunt)) { | 680 | if (empty($interfaceShunt)) { |
676 | return false; | 681 | return false; |
677 | } | 682 | } |
@@ -753,4 +758,4 @@ class Yohobuy | @@ -753,4 +758,4 @@ class Yohobuy | ||
753 | 758 | ||
754 | return $url; | 759 | return $url; |
755 | } | 760 | } |
756 | -} | 761 | +} |
@@ -94,6 +94,29 @@ class Cache | @@ -94,6 +94,29 @@ class Cache | ||
94 | } | 94 | } |
95 | 95 | ||
96 | /** | 96 | /** |
97 | + * 直接查询缓存,不对key做任何处理 | ||
98 | + */ | ||
99 | + public static function getBy($key, $node = 'master') | ||
100 | + { | ||
101 | + $result = array(); | ||
102 | + | ||
103 | + try { | ||
104 | + // WINDOWS | ||
105 | + if (DIRECTORY_SEPARATOR === '\\') { | ||
106 | + $result = HoodCache::Memcache($node)->getBy(key)); | ||
107 | + } | ||
108 | + // LINUX | ||
109 | + else { | ||
110 | + $result = HoodCache::Memcached($node)->getBy(key)); | ||
111 | + } | ||
112 | + } catch (Exception $e) { | ||
113 | + $result = array(); | ||
114 | + } | ||
115 | + | ||
116 | + return $result; | ||
117 | + } | ||
118 | + | ||
119 | + /** | ||
97 | * 清除缓存 | 120 | * 清除缓存 |
98 | * | 121 | * |
99 | * @param string $key 键名 | 122 | * @param string $key 键名 |
@@ -167,6 +167,11 @@ class Memcached extends Root implements CacheInterface | @@ -167,6 +167,11 @@ class Memcached extends Root implements CacheInterface | ||
167 | return $this->init()->get($this->_makeTag() . $key, $cacheCb, $casToken); | 167 | return $this->init()->get($this->_makeTag() . $key, $cacheCb, $casToken); |
168 | } | 168 | } |
169 | 169 | ||
170 | + public function getBy($key, $cacheCb = null, &$casToken = null) | ||
171 | + { | ||
172 | + return $this->init()->get($key, $cacheCb, $casToken); | ||
173 | + } | ||
174 | + | ||
170 | /** | 175 | /** |
171 | * 向一个新的key下面增加一个元素 | 176 | * 向一个新的key下面增加一个元素 |
172 | * @param $key | 177 | * @param $key |
1 | [memcached] | 1 | [memcached] |
2 | -master.hosts=127.0.0.1:11212,127.0.0.1:11213 | ||
3 | -slave.hosts=127.0.0.1:11212,127.0.0.1:11213 | ||
4 | -session.hosts=127.0.0.1:11212,127.0.0.1:11213 | 2 | +master.hosts=127.0.0.1:12111 |
3 | +slave.hosts=127.0.0.1:12111 | ||
4 | +session.hosts=127.0.0.1:12111 | ||
5 | 5 | ||
6 | [redis] | 6 | [redis] |
7 | servers.hosts = 127.0.0.1:6379 | 7 | servers.hosts = 127.0.0.1:6379 |
-
Please register or login to post a comment