Authored by biao

Merge remote-tracking branch 'origin/develop/wap' into beta/wap

... ... @@ -71,6 +71,21 @@ class Cache
else {
$result = HoodCache::Memcached($node)->get(self::makeKey($key, $node));
}
// 当接口异常,一级缓存没取到数据的情况
if ($node === 'slave') {
$incrementKey = self::makeKey('_increment_' . $key, 'slave');
$incrementValue = HoodCache::Memcached('slave')->get($incrementKey, 'slave');
// 接口调用失败累计5次之后,回填二级缓存数据到一级缓存, 重置计数值为0
if (is_int($incrementValue) && $incrementValue > 5) {
HoodCache::Memcached('master')->set(self::makeKey($key, 'master'), $result, 300);
HoodCache::Memcached('slave')->set($incrementKey, 0, 3600);
}
// 接口调用失败次数累加
else {
HoodCache::Memcached('slave')->increment($incrementKey, 1, 0, 3600);
}
}
} catch (Exception $e) {
$result = array();
}
... ... @@ -97,6 +112,32 @@ class Cache
HoodCache::Memcached('slave')->delete(self::makeKey($key, 'slave'));
}
}
/**
* 累加
*
* @param string $key
* @param int $offset
* @param int $initialValue
* @param int $expiry
* @return boolean
*/
public static function increment($key, $offset = 1, $initialValue = 0, $expiry = 0)
{
return HoodCache::Memcached('master')->increment(self::makeKey($key, 'master'), $offset, $initialValue, $expiry);
}
/**
* 递减
*
* @param string $key
* @param int $offset
* @return boolean
*/
public static function decrement($key, $offset = 1)
{
return HoodCache::Memcached('master')->decrement(self::makeKey($key, 'master'), $offset);
}
/**
* 生成键名
... ...
... ... @@ -490,7 +490,9 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
//延迟刷新,否则面板可能无法隐藏
setTimeout(function() {
window.location.reload();
//获取当前页面商品类型:普通商品/预售商品
window.location.href = '/cart/index/index?cartType=' + $('#cartType').val();
}, 1);
}
}).fail(function() {
... ...