redisキャッシュ・ロック・レコード、データベース・ロック・ローの使用
4286 ワード
public ResultBean issue(String originID, final Long userID, final String fromIp) {
try {
if (!cacheSessionStorage.lock(ISSUING_LOCK + userID)) {
return ResultBean.failed(Result.GLOBAL.FAIL.getCode(), " , , , 。");
}
Subject subjectDraft = subjectDraftDAO.getByOriginID(originID);
int limitCategory = subjectDraft.getLimitCategory().intValue();
if (LimitCategory.NET_VALUE.getType() == limitCategory) {
return issueNetValue(originID, userID, fromIp);
} else if (LimitCategory.CREDIT_LIMIT.getType() == limitCategory) {
return issueCredit(originID, userID, fromIp);
} else if (LimitCategory.FAST_LIMIT.getType() == limitCategory
|| LimitCategory.SPECIFIC.getType() == limitCategory
|| LimitCategory.DISCUSS.getType() == limitCategory
|| LimitCategory.ESSENCE.getType() == limitCategory
|| LimitCategory.GONGXIN.getType() == limitCategory) {
return issueFastLoan(originID, userID, fromIp);
} else if (LimitCategory.ASSETS_LIMIT.getType() == limitCategory) {
return issueAssets(originID, userID, fromIp);
} else {
throw new UserException(BeanCode.GLOBAL.FAIL.getCode(), " !");
}
}catch (Exception e){
throw new UserException(BeanCode.GLOBAL.FAIL.getCode(), e.getMessage());
}finally {
cacheSessionStorage.unlock(ISSUING_LOCK + userID);
}
}
2. redis , , , ,
, , 。