提交 b2fa82f8 编写于 作者: ibizdev's avatar ibizdev

hebao1234 发布系统代码 [ibz-dst,应用]

上级 73a9fe8e
......@@ -24,13 +24,13 @@ public interface DABuildMapper extends BaseMapper<DABuild> {
@Cacheable(value ="dabuild", key = "'row:'+#p0")
DABuild selectById(Serializable id);
@Override
@CacheEvict(value ="dabuild", key = "'row:'+#p0.build_id")
@CacheEvict(value ="dabuild", key = "'row:'+#p0.buildId")
int insert(DABuild entity);
@Override
@CacheEvict(value ="dabuild", key = "'row:'+#p0.build_id")
@CacheEvict(value ="dabuild", key = "'row:'+#p0.buildId")
int updateById(@Param(Constants.ENTITY) DABuild entity);
@Override
@CacheEvict(value ="dabuild", key = "'row:'+#p0.build_id")
@CacheEvict(value ="dabuild", key = "'row:'+#p0.buildId")
int update(@Param(Constants.ENTITY) DABuild entity, @Param("ew") Wrapper<DABuild> updateWrapper);
@Override
@CacheEvict(value ="dabuild", key = "'row:'+#p0")
......
......@@ -8,6 +8,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.util.StringUtils;
import org.springframework.util.ObjectUtils;
import java.util.Map;
import cn.ibizlab.util.cache.cache.LayeringCache;
import cn.ibizlab.util.enums.RedisChannelTopic;
......@@ -34,20 +35,25 @@ public class RedisMessageListener extends MessageListenerAdapter {
if(result instanceof Map){
map= (Map<String, Object>) result;
}
if(StringUtils.isEmpty(map)|| (!map.containsKey("cacheName"))|| (!map.containsKey("key"))){
if(StringUtils.isEmpty(map)|| (!map.containsKey("cacheName"))){
log.debug("解析缓存数据失败,无法获取指定值!");
return ;
}
log.debug("redis消息订阅者接收到频道【{}】发布的消息。消息内容:{}", channelTopic.getChannelTopicStr(), result.toString());
String cacheName = (String) map.get("cacheName");
Object key = map.get("key");
Cache cache = cacheManager.getCache(cacheName);// 根据缓存名称获取多级缓存
if (cache != null && cache instanceof LayeringCache) { // 判断缓存是否是多级缓存
switch (channelTopic) {
case REDIS_CACHE_DELETE_TOPIC: // 获取一级缓存,并删除一级缓存数据
((LayeringCache) cache).getFirstCache().evict(key);
((LayeringCache) cache).getSecondCache().evict(key);
log.debug("同步删除缓存{}数据,key:{},", cacheName, key.toString());
Object cacheKey = map.get("key");
if(!ObjectUtils.isEmpty(cacheKey)){
((LayeringCache) cache).getFirstCache().evict(cacheKey);
((LayeringCache) cache).getSecondCache().evict(cacheKey);
log.debug("同步删除缓存{}数据,key:{},", cacheName, cacheKey.toString());
}
else{
log.debug("同步删除缓存失败,{}缓存键值为空!",cacheName);
}
break;
case REDIS_CACHE_CLEAR_TOPIC:// 获取一级缓存,并删除一级缓存数据
((LayeringCache) cache).getFirstCache().clear();
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册