String transaction_id = 数据库或业务消息中变动的唯一值;
int hash = transaction_id.hashCode() ^ (transaction_id.hashCode() << 16);
String url;
if ((hash & 2) == 0) {
syso("负载分发0")
} else {
syso("负载分发1")
}
通过获取String hashcode值 和 移位 的交集生成新值,然后 &2 值来对2进行 取模
String transaction_id = 数据库或业务消息中变动的唯一值;
int hash = transaction_id.hashCode() ^ (transaction_id.hashCode() << 16);
String url;
if ((hash & 2) == 0) {
syso("负载分发0")
} else {
syso("负载分发1")
}
通过获取String hashcode值 和 移位 的交集生成新值,然后 &2 值来对2进行 取模