[SpringBoot] SpringBoot integrate Redis cache (XIX)] [SpringBoot SpringBoot cache (xviii)] [SpringBoot SpringBoot cache (XVIII)

  This chapter describes SpringBoot and Redis integration, caching can not understand the reference [SpringBoot] SpringBoot cache (XVIII)

Redis integration

  1, SpringBoot Web project to build, reference [SpringBoot] SpringBoot cache (XVIII)

  2, the introduction SpringBoot starter redis

1 <dependency>
2     <groupId>org.springframework.boot</groupId>
3     <artifactId>spring-boot-starter-data-redis</artifactId>
4 </dependency>

    View dependence, starter relied jedis

1 <dependency>
2     <groupId>redis.clients</groupId>
3     <artifactId>jedis</artifactId>
4     <version>${jedis}</version>
5     <optional>true</optional>
6 </dependency>

  3, application.yml connection address configuration redis

    redis stand-alone configuration

. 1  Spring:
 2    Redis:
 . 3      # host address
 . 4      Host: 127.0.0.1
 . 5      # default port
 . 6      Port: 6379
 . 7      # password
 . 8      password: 123456

    redis machine configuration

    redis Sentinel Mode Configuration

1 spring:
2   redis:
3     password: 123456
4     sentinel:
5       master: mymaster
6       nodes:
7         - 127.0.0.1:6379
8         - 127.0.0.2:6379
9         - 127.0.0.3:6379
View Code

 

 

 

 

Starter-Boot-introduction-Spring Data-redis
application.yml redis connection address configuration
using the operating RestTemplate redis
redisTemplate.opsForValue (); // string operation
redisTemplate.opsForHash (); // operating the hash
redisTemplate.opsForList (); // operation List
redisTemplate.opsForSet (); // operator set
redisTemplate.opsForZSet (); // operations in the ordered set
configuration cache, CacheManagerCustomizers
test using the cache, the cache is switched, CompositeCacheManager

 

Guess you like

Origin www.cnblogs.com/h--d/p/12466473.html