分布式锁注解最佳实践

This commit is contained in:
zhongzb
2023-04-22 22:49:11 +08:00
parent 3ea4bb9953
commit 0d2ba4e70a
10 changed files with 248 additions and 29 deletions

View File

@@ -1,5 +1,6 @@
package com.abin.mallchat.common.user.service.impl;
import com.abin.mallchat.common.common.annotation.RedissonLock;
import com.abin.mallchat.common.common.domain.enums.IdempotentEnum;
import com.abin.mallchat.common.common.domain.enums.YesOrNoEnum;
import com.abin.mallchat.common.user.dao.ItemConfigDao;
@@ -32,6 +33,7 @@ public class UserBackpackServiceImpl implements IUserBackpackService {
private ItemCache itemCache;
@Override
@RedissonLock(key = "#uid")
public void acquireItem(Long uid, Long itemId, IdempotentEnum idempotentEnum, String businessId) {//todo 分布式锁
String idempotent = getIdempotent(itemId, idempotentEnum, businessId);
UserBackpack userBackpack = userBackpackDao.getByIdp(idempotent);