wyh-spring-ecosystem-student / spring-boot-student Goto Github PK
View Code? Open in Web Editor NEWspring-boot-student
License: Other
spring-boot-student
License: Other
MybatisRedisCache 使用redis作为二级缓存,设置了flushInterval值,但什么时候移除redis缓存的值呢?
是redis的过期时间,还是调用removeobject()方法?
// 分布式服务器有时差,这里给1秒的误差值
expires = System.currentTimeMillis() + expireTime + 1;
应该改为:
expires = System.currentTimeMillis() + expireTime * 1000 + 1*1000;
因为currentTimeMillis单位是毫秒,但你l输入参数定义的expireTime是秒的
将rabbitmq exchange test-send-award-exchange删掉,调用send,输出日志
MQ消息发送失败,消息重发,消息ID:a75b5579-1c9a-4908-929b-1a02af1a487b,重发次数:0,消息体:{"age":20,"id":1,"name":"12"}
但是没有进一步重发
项目怎么没有用到缓存
LayeringCacheManager内的RedisCachePrefix
RedisLock
CustomizedRedisCache
我看到你使用redis+Caffeine的例子,非常好,准备整合到我的工程中,这三个文件太难升级修改。
怎么能让每个定时任务的日志中添加当前定时任务的方法路径呢
您好,我没跑起来看,但是看了下您的代码,发现CustomizedRedisCacheManager 这个类里面定义了四个常量,是用来在合适的时机反射父类,获取父类(RedisCacheManager)属性和方法的,但是发现,cacheMap属性和updateCacheNames这个方法,在父类乃至祖类 都是不存在的,是因为版本问题么?也不对啊,刚从git上拉下来的, 版本是完全跟着您定义的版本号走的,难道之前是老版本,后来因为其他模块改成了新版本,而忽略了此处的反射方法的问题?
public RedisCacheElement get(final RedisCacheKey cacheKey) {
Assert.notNull(cacheKey, "CacheKey must not be null!");
// 根据key获取缓存值
RedisCacheElement redisCacheElement = new RedisCacheElement(cacheKey, fromStoreValue(lookup(cacheKey)));
// 判断key是否存在
Boolean exists = (Boolean) redisOperations.execute(new RedisCallback<Boolean>() {
@Override
public Boolean doInRedis(RedisConnection connection) throws DataAccessException {
return connection.exists(cacheKey.getKeyBytes());
}
});
if (!exists.booleanValue()) {
return null;
}
return redisCacheElement;
}
此处先获取redis的缓存,再判断redis中是否存在缓存key。存在第一步redis获取的缓存为null,此时其他机器向redis缓存数据,然后第二步判断key存在,导致返回了一个value为null的RedisCacheElement对象。
实测确实发生了这种情况。 我觉得判断部分应该修改为
if (!exists.booleanValue() || redisCacheElement.get() == null) {
return null;
}
return redisCacheElement;
但是我很奇怪,为什么源码不直接判断redisCacheElement.get()不为null的时候就返回RedisCacheElement对象,却用判断redis是否存在key的方法。
RedisCacheElement redisCacheElement = new RedisCacheElement(cacheKey, fromStoreValue(lookup(cacheKey)));
这里的 fromStoreValue 和 lookup 呢 ?
<dependency>
<groupId>com.xiaolyuh</groupId>
<artifactId>layering-cache-aspectj</artifactId>
<version>1.0.0</version>
</dependency>
this jar can`t downloaded
Failed to execute goal on project spring-boot-student-layering-cache: Could not resolve dependencies for project com.xiaolyuh:spring-boot-student-layering-cache:jar:0.0.1-SNAPSHOT: Could not find artifact com.xiaolyuh:layering-cache-aspectj:jar:1.0.0 in alimaven (http://maven.aliyun.com/nexus/content/groups/public/) -> [Help 1]
so where is the places to download this jar ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.