pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
yml配置文件
# Redis服务器连贯端口
spring.redis.port=6379
# Redis服务器地址
spring.redis.host=127.0.0.1
# Redis数据库索引(默认为0)
spring.redis.database=0
# Redis服务器连贯明码(默认为空)
spring.redis.password=
# 连接池最大连接数(应用负值示意没有限度)
spring.redis.jedis.pool.max-active=8
# 连接池最大阻塞等待时间(应用负值示意没有限度)
spring.redis.jedis.pool.max-wait=-1ms
# 连接池中的最大闲暇连贯
spring.redis.jedis.pool.max-idle=8
# 连接池中的最小闲暇连贯
spring.redis.jedis.pool.min-idle=0
# 连贯超时工夫(毫秒)
spring.redis.timeout=5000ms
写代码
@SpringBootTest
class DemoApplicationTests {
@Autowired
RedisTemplate redisTemplate;
@Test
void redistEST() {
redisTemplate.boundValueOps("name").set("asdads");
}
@Test
void redistjST() {
Object name = redisTemplate.boundValueOps("name").get();
System.out.println(name);
}
}
ValueOperations:简略K-V操作
SetOperations:set类型数据操作
ZSetOperations:zset类型数据操作
HashOperations:针对map类型的数据操作
ListOperations:针对list类型的数据操作
如果你在运行这个代码的过程中有遇到问题,请加小编vi信xxf960513,!帮忙你疾速把握这个性能代码!
发表回复