首页 > IT职业 > IT生活 > SpringBoot整合Redis开发
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-data-redisartifactId>
dependency>
# 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类型的数据操作
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4606/viewspace-2797365/ ,如需转载,请注明出处,否则将追究法律责任。