redisUtilPool
This commit is contained in:
@@ -24,17 +24,13 @@ import com.cool.store.service.PreparationService;
|
||||
import com.cool.store.service.SysStoreAppService;
|
||||
import com.cool.store.service.UserAuthMappingService;
|
||||
import com.cool.store.utils.RedisUtilPool;
|
||||
import com.cool.store.utils.poi.StringUtils;
|
||||
import com.cool.store.utils.poi.constant.Constants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -87,9 +83,6 @@ public class SysStoreAppServiceImpl implements SysStoreAppService, AuditResultSe
|
||||
@Resource
|
||||
PointDetailInfoMapper pointDetailInfoMapper;
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
RedisUtilPool redisUtilPool;
|
||||
|
||||
@@ -104,7 +97,7 @@ public class SysStoreAppServiceImpl implements SysStoreAppService, AuditResultSe
|
||||
String lockValue = UUID.randomUUID().toString();
|
||||
boolean acquired = false;
|
||||
try {
|
||||
acquired = stringRedisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 10, TimeUnit.SECONDS);
|
||||
acquired = redisUtilPool.setNxExpire(lockKey, lockValue, 10);
|
||||
if (Boolean.TRUE.equals(acquired)) {
|
||||
//1.操作数据库
|
||||
SystemBuildingShopDO systemBuildingShopDO = SystemBuildingShopDO.convertToSystemBuildingShopDO(request);
|
||||
@@ -126,9 +119,9 @@ public class SysStoreAppServiceImpl implements SysStoreAppService, AuditResultSe
|
||||
}
|
||||
}finally {
|
||||
if (Boolean.TRUE.equals(acquired)) {
|
||||
String currentValue = stringRedisTemplate.opsForValue().get(lockKey);
|
||||
String currentValue = redisUtilPool.getString(lockKey);
|
||||
if (lockValue.equals(currentValue)) {
|
||||
stringRedisTemplate.delete(lockKey);
|
||||
redisUtilPool.delKey(lockKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user