Authored by 姜枫

edit shut memcache read

... ... @@ -165,7 +165,7 @@ class Yohobuy
$url = self::httpBuildQuery($url, $data);
} //echo $url;
UdpLog::debug('get api', $url);
UdpLog::debug('get shut api', $url);
/* 开启缓存的情况 */
if ($cache && USE_CACHE) {
... ... @@ -243,6 +243,8 @@ class Yohobuy
if (!empty($userAgent)) {
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
}
UdpLog::debug('call api: ', $url);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
... ... @@ -670,8 +672,11 @@ class Yohobuy
return false;
}
$interfaceShunt = Cache::get('INTERFACE_SHUT_KEY', 'master');
UdpLog::debug('read memcache');
$interfaceShunt = Cache::getBy('INTERFACE_SHUT_KEY', 'master');
UdpLog::debug('read memcahe: ', $interfaceShunt);
if (empty($interfaceShunt)) {
return false;
}
... ... @@ -753,4 +758,4 @@ class Yohobuy
return $url;
}
}
}
\ No newline at end of file
... ...
... ... @@ -94,6 +94,29 @@ class Cache
}
/**
* 直接查询缓存,不对key做任何处理
*/
public static function getBy($key, $node = 'master')
{
$result = array();
try {
// WINDOWS
if (DIRECTORY_SEPARATOR === '\\') {
$result = HoodCache::Memcache($node)->getBy(key));
}
// LINUX
else {
$result = HoodCache::Memcached($node)->getBy(key));
}
} catch (Exception $e) {
$result = array();
}
return $result;
}
/**
* 清除缓存
*
* @param string $key 键名
... ...
... ... @@ -167,6 +167,11 @@ class Memcached extends Root implements CacheInterface
return $this->init()->get($this->_makeTag() . $key, $cacheCb, $casToken);
}
public function getBy($key, $cacheCb = null, &$casToken = null)
{
return $this->init()->get($key, $cacheCb, $casToken);
}
/**
* 向一个新的key下面增加一个元素
* @param $key
... ...
[memcached]
master.hosts=127.0.0.1:11212,127.0.0.1:11213
slave.hosts=127.0.0.1:11212,127.0.0.1:11213
session.hosts=127.0.0.1:11212,127.0.0.1:11213
master.hosts=127.0.0.1:12111
slave.hosts=127.0.0.1:12111
session.hosts=127.0.0.1:12111
[redis]
servers.hosts = 127.0.0.1:6379
\ No newline at end of file
... ...