更新sql和代码规范修改
This commit is contained in:
@ -20,7 +20,7 @@ public class YshopCacheAutoConfiguration {
|
||||
|
||||
/**
|
||||
* RedisCacheConfiguration Bean
|
||||
*
|
||||
* <p>
|
||||
* 参考 org.springframework.boot.autoconfigure.cache.RedisCacheConfiguration 的 createConfiguration 方法
|
||||
*/
|
||||
@Bean
|
||||
|
@ -33,12 +33,13 @@ public class YshopRedisAutoConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* /
|
||||
* /
|
||||
*
|
||||
* @param redissonClient /
|
||||
* @return Redisson 操作工具类
|
||||
*/
|
||||
@Bean
|
||||
public RedissonUtil redissonUtil(RedissonClient redissonClient){
|
||||
public RedissonUtil redissonUtil(RedissonClient redissonClient) {
|
||||
return new RedissonUtil(redissonClient);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class RedisKeyDefine {
|
||||
private final KeyTypeEnum keyType;
|
||||
/**
|
||||
* Value 类型
|
||||
*
|
||||
* <p>
|
||||
* 如果是使用分布式锁,设置为 {@link java.util.concurrent.locks.Lock} 类型
|
||||
*/
|
||||
private final Class<?> valueType;
|
||||
@ -100,7 +100,7 @@ public class RedisKeyDefine {
|
||||
|
||||
/**
|
||||
* 格式化 Key
|
||||
*
|
||||
* <p>
|
||||
* 注意,内部采用 {@link String#format(String, Object...)} 实现
|
||||
*
|
||||
* @param args 格式化的参数
|
||||
|
@ -24,13 +24,14 @@ public class RedissonUtil {
|
||||
|
||||
/**
|
||||
* 向指定key的延时队列中添加任务
|
||||
* @param key 延时队列
|
||||
* @param v 订单id
|
||||
* @param delay 延时时长
|
||||
*
|
||||
* @param key 延时队列
|
||||
* @param v 订单id
|
||||
* @param delay 延时时长
|
||||
* @param timeUnit 延时单位
|
||||
* @param <V> id类型
|
||||
* @param <V> id类型
|
||||
*/
|
||||
public <V> void delayedOffer(String key,V v,long delay, TimeUnit timeUnit){
|
||||
public <V> void delayedOffer(String key, V v, long delay, TimeUnit timeUnit) {
|
||||
try {
|
||||
RBlockingDeque<Object> blockingDeque = redissonClient.getBlockingDeque(key);
|
||||
RDelayedQueue<Object> delayedQueue = redissonClient.getDelayedQueue(blockingDeque);
|
||||
@ -44,14 +45,15 @@ public class RedissonUtil {
|
||||
|
||||
/**
|
||||
* 向指定key的延时队列中添加任务
|
||||
* @param key 延时队列
|
||||
* @param v 订单id
|
||||
* @param delay 延时时长
|
||||
*
|
||||
* @param key 延时队列
|
||||
* @param v 订单id
|
||||
* @param delay 延时时长
|
||||
* @param timeUnit 延时单位
|
||||
* @param code 添加失败抛出异常
|
||||
* @param <V> id类型
|
||||
* @param code 添加失败抛出异常
|
||||
* @param <V> id类型
|
||||
*/
|
||||
public <V> void delayedOfferThrow(String key, V v, long delay, TimeUnit timeUnit, ErrorCode code){
|
||||
public <V> void delayedOfferThrow(String key, V v, long delay, TimeUnit timeUnit, ErrorCode code) {
|
||||
try {
|
||||
RBlockingDeque<Object> blockingDeque = redissonClient.getBlockingDeque(key);
|
||||
RDelayedQueue<Object> delayedQueue = redissonClient.getDelayedQueue(blockingDeque);
|
||||
@ -60,18 +62,19 @@ public class RedissonUtil {
|
||||
logger.info("添加延时队列成功 ,延迟时间:" + s + "订单id: " + v);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
throw ServiceExceptionUtil.exception(code,e.getMessage());
|
||||
throw ServiceExceptionUtil.exception(code, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向指定key的延时队列中删除任务
|
||||
* @param key 延时队列
|
||||
* @param v 订单id
|
||||
*
|
||||
* @param key 延时队列
|
||||
* @param v 订单id
|
||||
* @param code 添加失败抛出异常
|
||||
* @param <V> id类型
|
||||
* @param <V> id类型
|
||||
*/
|
||||
public <V> void delayedRemoveThrow(String key, V v, ErrorCode code){
|
||||
public <V> void delayedRemoveThrow(String key, V v, ErrorCode code) {
|
||||
try {
|
||||
RBlockingDeque<Object> blockingDeque = redissonClient.getBlockingDeque(key);
|
||||
RDelayedQueue<Object> delayedQueue = redissonClient.getDelayedQueue(blockingDeque);
|
||||
@ -79,7 +82,7 @@ public class RedissonUtil {
|
||||
logger.info("删除延时队列成功 , 订单id: " + v);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
throw ServiceExceptionUtil.exception(code,e.getMessage());
|
||||
throw ServiceExceptionUtil.exception(code, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user