提交 9a5aa5d9 编写于 作者: S studyingpanda

chen

上级 ded4646d
......@@ -34,16 +34,22 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<!-- Ehcache 依赖 -->
<!-- Redis 相关依赖 -->
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</dependency>
<!-- cache-api 依赖 -->
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<!-- Ehcache 依赖 <dependency> <groupId>org.ehcache</groupId> <artifactId>ehcache</artifactId>
</dependency> <dependency> <groupId>javax.cache</groupId> <artifactId>cache-api</artifactId>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
......
spring.cache.jcache.config=classpath:ehcache.xml
spring.cache.type=jcache
\ No newline at end of file
# ehcache
# spring.cache.jcache.config=classpath:ehcache.xml
# spring.cache.type=jcache
# 过期时间
spring.cache.redis.time-to-live=6000s
# Redis库的编号
spring.redis.database=0
# Redis实例地址
spring.redis.host=127.0.0.1
# Redis实例端口号,默认6379
spring.redis.port=6379
# Redis登录密码
spring.redis.password=Easy@0122
# Redis连接池最大连接数
spring.redis.jredis.pool.max-active=10
# Redis连接池最大空闲连接数
spring.redis.jedis.pool.max-idle=10
# Redis连接池最小空闲连接数
spring.redis.jedis.pool.min-idle=0
\ No newline at end of file
......@@ -40,8 +40,9 @@ class SpringBootCacheApplicationTests {
GoodsDo temp = new GoodsDo();
temp.setId(1L);
temp.setName("新的商品");
GoodsDo newGoods = goodsService.edit(temp);
// 打印缓存内容
goodsService.edit(temp);
// 查询并打印已更新的缓存内容
GoodsDo newGoods = goodsService.getById(1L);
logger.info("new goods id:{} name:{}", newGoods.getId(), newGoods.getName());
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册