Redis is a very popular cache database. The specific technical details are not described here

At present, the project uses Spring Boot to achieve, SO I also come to something fresh, to tell the truth, it really works.

Let’s talk about the dependency of use

<dependencies>  
     <dependency>  
           <groupId>org.springframework.boot</groupId>  
          <artifactId>spring-boot-starter-data-redis</artifactId>  
     </dependency>  
     <dependency>  
           <groupId>com.alibaba</groupId>  
           <artifactId>fastjson</artifactId>  
     </dependency>  
     <dependency>  
           <groupId>org.springframework.boot</groupId>  
          <artifactId>spring-boot-configuration-processor</artifactId>  
           <optional>true</optional>  
     </dependency>  
  </dependencies>  
Copy the code

1. Basic configuration, which is indispensable regardless of configuration file or config. Here I learned the features of Spring Boot. Redis starts by default as long as the package is loaded in the company project. There are two sentinel Cluster modes available in Redis

Sentinel configuration class

package com.ecej.nove.redis.config;  
  
import java.util.HashSet;  
  
import javax.annotation.Resource;  
  
import org.slf4j.Logger;  
import org.slf4j.LoggerFactory;  
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;  
import org.springframework.boot.context.properties.EnableConfigurationProperties;  
import org.springframework.context.annotation.Bean;  
import org.springframework.context.annotation.Configuration;  
import org.springframework.data.redis.connection.RedisSentinelConfiguration;  
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;  
import org.springframework.data.redis.core.RedisTemplate;  
import org.springframework.data.redis.serializer.StringRedisSerializer;  
import org.springframework.util.StringUtils;  
  
import redis.clients.jedis.JedisPoolConfig;  
  
/** 
 *  
 * @author QIANG 
 * 
 */  
@Configuration  
@EnableConfigurationProperties(EcejRedisProperties.class)  
@ConditionalOnProperty(name = "ecej.redis.sentinel")  
public class RedisSentinelConfig {  
    private Logger LOG = LoggerFactory.getLogger(RedisSentinelConfig.class);  
  
    @Resource  
    private EcejRedisProperties redisProperties;  
  
    public JedisPoolConfig jedisPoolConfig() {  
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();  
        jedisPoolConfig.setMaxIdle(redisProperties.getMaxIdle());  
        jedisPoolConfig.setMaxTotal(redisProperties.getMaxTotal());  
        jedisPoolConfig.setMaxWaitMillis(redisProperties.getMaxWaitMillis());  
        return jedisPoolConfig;  
  
    }  
  
    public RedisSentinelConfiguration jedisSentinelConfig() {  
        String[] hosts = redisProperties.getHostName().split(",");  
        HashSet<String> sentinelHostAndPorts = new HashSet<>();  
        for (String hn : hosts) {  
            sentinelHostAndPorts.add(hn);  
        }  
        return new RedisSentinelConfiguration(redisProperties.getMastername(), sentinelHostAndPorts);  
  
    }  
  
    @Bean  
    public JedisConnectionFactory jedisConnectionFactory() {  
  
        JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(jedisSentinelConfig(),  
                jedisPoolConfig());  
        if(! StringUtils.isEmpty(redisProperties.getPassword())) jedisConnectionFactory.setPassword(redisProperties.getPassword());return jedisConnectionFactory;  
    }  
  
    @Bean  
    public RedisTemplate<String, String> redisTemplate() {  
  
        RedisTemplate<String, String> redisTemplate = new RedisTemplate<>();  
        redisTemplate.setConnectionFactory(jedisConnectionFactory());  
        redisTemplate.setDefaultSerializer(new StringRedisSerializer());  
        LOG.info("create redisTemplate success");  
        returnredisTemplate; }}Copy the code

The cluster configuration is posted below

package com.ecej.nove.redis.config;  
  
import java.util.HashSet;  
import java.util.Set;  
  
import javax.annotation.Resource;  
  
import org.slf4j.Logger;  
import org.slf4j.LoggerFactory;  
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;  
import org.springframework.boot.context.properties.EnableConfigurationProperties;  
import org.springframework.context.annotation.Bean;  
import org.springframework.context.annotation.Configuration;  
import org.springframework.data.redis.connection.RedisClusterConfiguration;  
import org.springframework.data.redis.connection.RedisClusterNode;  
import org.springframework.data.redis.connection.RedisNode;  
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;  
import org.springframework.data.redis.core.RedisTemplate;  
import org.springframework.data.redis.serializer.StringRedisSerializer;  
import org.springframework.util.StringUtils;  
  
import redis.clients.jedis.JedisPoolConfig;  
  
/** 
 *  
 * @author QIANG 
 * 
 */  
@Configuration  
@EnableConfigurationProperties(EcejRedisProperties.class)  
@ConditionalOnProperty(name = "ecej.redis.cluster")  
public class RedisClusterConfig {  
    private Logger LOG = LoggerFactory.getLogger(RedisClusterConfig.class);  
  
    @Resource  
    private EcejRedisProperties redisProperties;  
  
    public JedisPoolConfig jedisPoolConfig() {  
  
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();  
        jedisPoolConfig.setMaxIdle(redisProperties.getMaxIdle());  
        jedisPoolConfig.setMaxTotal(redisProperties.getMaxTotal());  
        jedisPoolConfig.setMaxWaitMillis(redisProperties.getMaxWaitMillis());  
        return jedisPoolConfig;  
  
    }  
  
    public RedisClusterConfiguration redisClusterConfiguration() {  
  
        RedisClusterConfiguration redisClusterConfiguration = new RedisClusterConfiguration();  
        String[] hosts = redisProperties.getHostName().split(":");  
        Set<RedisNode> redisNodes = new HashSet<>();  
        redisNodes.add(new RedisClusterNode(hosts[0], Integer.valueOf(hosts[1])));  
        redisClusterConfiguration.setClusterNodes(redisNodes);  
        redisClusterConfiguration.setMaxRedirects(redisProperties.getMaxRedirects());  
        return redisClusterConfiguration;  
  
    }  
  
    @Bean  
    public JedisConnectionFactory jedisConnectionFactory() {  
        JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(redisClusterConfiguration(),  
                jedisPoolConfig());  
        if(! StringUtils.isEmpty(redisProperties.getPassword())) jedisConnectionFactory.setPassword(redisProperties.getPassword());return jedisConnectionFactory;  
    }  
  
    @Bean  
    public RedisTemplate<String, String> redisTemplate() {  
  
        RedisTemplate<String, String> redisTemplate = new RedisTemplate<>();  
        redisTemplate.setConnectionFactory(jedisConnectionFactory());  
        redisTemplate.setDefaultSerializer(new StringRedisSerializer());  
        LOG.info("create RedisTemplate success");  
        returnredisTemplate; }} ` ` ` using configuration class, used to load parameters ` ` ` package. Com ecej. Nove. Redis. Config. import org.springframework.boot.context.properties.ConfigurationProperties; /** * * @author QIANG * */ @ConfigurationProperties(prefix ="ecej.redis")  
public class EcejRedisProperties {  
  
     /** 
      * Max number of "idle" connections inthe pool. Use a negative value to * indicate an unlimited number of idle connections. */ private int maxIdle = 10; /** * private int maxTotal = 500; private int maxWaitMillis = 3000; private String hostName ="localhost";  
  
     private String password;  
  
     /** 
      * Maximum number of redirects to follow when executing commands across the 
      * cluster. 
      */  
     private int maxRedirects = 10;  
  
     private String mastername;  
  
     public int getMaxIdle() {  
           return maxIdle;  
     }  
  
     public void setMaxIdle(int maxIdle) {  
           this.maxIdle = maxIdle;  
     }  
  
     public int getMaxTotal() {  
           return maxTotal;  
     }  
  
     public void setMaxTotal(int maxTotal) {  
           this.maxTotal = maxTotal;  
     }  
  
     public int getMaxWaitMillis() {  
           return maxWaitMillis;  
     }  
  
     public void setMaxWaitMillis(int maxWaitMillis) {  
           this.maxWaitMillis = maxWaitMillis;  
     }  
  
     public String getHostName() {  
           return hostName;  
     }  
  
     public void setHostName(String hostName) {  
           this.hostName = hostName;  
     }  
  
     public String getPassword() {  
           return password;  
     }  
  
     public void setPassword(String password) {  
           this.password = password;  
     }  
  
     public int getMaxRedirects() {  
           return maxRedirects;  
     }  
  
     public void setMaxRedirects(int maxRedirects) {  
           this.maxRedirects = maxRedirects;  
     }  
  
     public String getMastername() {  
           return mastername;  
     }  
  
     public void setMastername(String mastername) { this.mastername = mastername; }}Copy the code

How do I use it? I write a shortcut to use it, right

package com.ecej.nove.redis.utils;  
  
import java.util.ArrayList;  
import java.util.List;  
import java.util.Map;  
import java.util.Set;  
import java.util.concurrent.TimeUnit;  
  
import javax.annotation.PostConstruct;  
import javax.annotation.Resource;  
  
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;  
import org.springframework.data.redis.core.ListOperations;  
import org.springframework.data.redis.core.RedisCallback;  
import org.springframework.data.redis.core.RedisTemplate;  
import org.springframework.data.redis.core.SetOperations;  
import org.springframework.data.redis.core.ValueOperations;  
  
import com.alibaba.fastjson.JSON;  
import com.alibaba.fastjson.parser.Feature;  
  
/** 
 * 
 * @author QIANG 
 * 
 */  
public class JedisClusterUtils {  
  
    @Resource  
    private RedisTemplate<String, String> redisTemplate;  
  
    private static JedisClusterUtils cacheUtils;  
  
    @PostConstruct  
    public void init() { cacheUtils = this; cacheUtils.redisTemplate = this.redisTemplate; } /** ** store data in cache ** @param key * @param val * @return*/ public static void saveString(String key, String val) { ValueOperations<String, String> vo = cacheUtils.redisTemplate.opsForValue(); vo.set(key, val); } /** * store the data in the cached collection ** @param key * @param val * @return*/ public static void saveToSet(String key, String val) { SetOperations<String, String> so = cacheUtils.redisTemplate.opsForSet(); so.add(key, val); } /** ** * @param key * Cache key * @return keyValue 
     * @author:mijp 
     * @since:2017/1/16 13:23 
     */  
    public static String getFromSet(String key) {  
        returncacheUtils.redisTemplate.opsForSet().pop(key); } /** * saves the value of key as value if and only if the key does not exist. If the given key already exists, SETNX does nothing. SETNX is "SET *"ifShort for "Not eXists" (if it does Not exist, SET). <br> * Saved successfully, returntrue<br> * Save failed, returnfalse*/ public static Boolean saveNX(String key, String val) {/** if the value is set successfully, 1 is returned. If the value fails, 0 is returnedreturn cacheUtils.redisTemplate.execute((RedisCallback<Boolean>) connection -> {  
            returnconnection.setNX(key.getBytes(), val.getBytes()); }); } /** * saves the value of key as value if and only if the key does not exist. If the given key already exists, SETNX does nothing. SETNX is "SET *"ifShort for "Not eXists" (if it does Not exist, SET). <br> * Saved successfully, returntrue<br> * Save failed, returnfalse* * @param key * @param val * @param expire * timeout * @returnSaved successfully, returntrueOtherwise returnsfalse 
     */  
    public static boolean saveNX(String key, String val, int expire) {  
  
        boolean ret = saveNX(key, val);  
        if (ret) {  
            cacheUtils.redisTemplate.expire(key, expire, TimeUnit.SECONDS);  
        }  
        returnret; } /** * store data in cache (and set expiration time) ** @param key * @param val * @param seconds * @return*/ public static void saveString(String key, String val, int seconds) { cacheUtils.redisTemplate.opsForValue().set(key, val, seconds, TimeUnit.SECONDS); } / * * * add the variables stored in cache * / public static void saveSeq (String key, long seqNo) {cacheUtils. RedisTemplate. Delete (key); cacheUtils.redisTemplate.opsForValue().increment(key, seqNo); } /** * public static void saveFloat(String key,floatdata) { cacheUtils.redisTemplate.delete(key); cacheUtils.redisTemplate.opsForValue().increment(key, data); } /** * Save complex type data to cache ** @param key * @param obj * @return*/ public static void saveBean(String key, Object obj) { cacheUtils.redisTemplate.opsForValue().set(key, JSON.toJSONString(obj)); } /** * Save complex type data to cache (and set expiration time) ** @param key * @param Object * @param seconds * @return*/ public static void saveBean(String key, Object obj, int seconds) { cacheUtils.redisTemplate.opsForValue().set(key, JSON.toJSONString(obj), seconds, TimeUnit.SECONDS); } /** * function: save to the specified queue <br /> * left near right <br /> author: * * @param key * @param val * @param size */ public static void saveToQueue(String key, String val, long size) {ListOperations<String, String> lo = cacheUtils.redisTemplate.opsForList();if(size > 0 && lo.size(key) >= size) { lo.rightPop(key); } lo.leftPush(key, val); } /** * save tohashPublic static void * @param hName * @param key * @param val */hashSet(String hName, String key, String value) { cacheUtils.redisTemplate.opsForHash().put(hName, key, value); } /** * get all values by key ** @param key * @return 
     */  
    public static Map<Object, Object> hgetAll(String key) {  
  
        returncacheUtils.redisTemplate.opsForHash().entries(key); } /** * save tohashPublic static <T> void * * @param <T> * * @param hName * @param key * @param val */hashSet(String hName, String key, T t) {  
  
        hashSet(hName, key, JSON.toJSONString(t)); } /** * get complex type data ** @param key * @param obj * @param clazz * @return 
     */  
    public static <T> T getBean(String key, Class<T> clazz) {  
  
        String value = cacheUtils.redisTemplate.opsForValue().get(key);  
        if (value == null) {  
            return null;  
        }  
        returnJSON.parseObject(value, clazz); } /** * retrieve string data from the cache ** @param key * @returnData * / public static String get String (String key) {cacheUtils. RedisTemplate. OpsForValue () get (key);returncacheUtils.redisTemplate.opsForValue().get(key); ** @param key * @param size * data length * @return 
     */  
    public static List<String> getFromQueue(String key, long size) {  
  
        boolean flag = cacheUtils.redisTemplate.execute((RedisCallback<Boolean>) connection -> {  
            return connection.exists(key.getBytes());  
        });  
  
        if (flag) {  
            return new ArrayList<>();  
        }  
        ListOperations<String, String> lo = cacheUtils.redisTemplate.opsForList();  
        if (size > 0) {  
            return lo.range(key, 0, size - 1);  
        } else {  
            returnlo.range(key, 0, lo.size(key) - 1); }} /** ** function: get data from the specified queue <br /> *return 
     */  
    public static String popQueue(String key) {  
  
        returncacheUtils.redisTemplate.opsForList().rightPop(key); } /** * gets the next ** @param key * @ of the sequence valuereturn 
     */  
    public static Long getSeqNext(String key) {  
  
        return cacheUtils.redisTemplate.execute((RedisCallback<Long>) connection -> {  
  
            returnconnection.incr(key.getBytes()); }); } /** * gets the next ** @param key * @ of the sequence valuereturn 
     */  
    public static Long getSeqNext(String key, long value) {  
  
        return cacheUtils.redisTemplate.execute((RedisCallback<Long>) connection -> {  
  
            returnconnection.incrBy(key.getBytes(), value); }); } /** * back the sequence value by a ** @param key * @return*/ public static void getSeqBack(String key) { cacheUtils.redisTemplate.execute((RedisCallback<Long>) connection -> connection.decr(key.getBytes())); } / * * * fromhashGet @param hName @param key @return 
     */  
    public static Object hashGet(String hName, String key) {  
  
        return cacheUtils.redisTemplate.opsForHash().get(hName, key);  
    }  
  
    public static <T> T hashGet(String hName, String key, Class<T> clazz) {  
  
        return JSON.parseObject((String) hashGet(hName, key), clazz); } /** * increments the value of a floating point number ** @param key * @return 
     */  
    public static Double incrFloat(String key, double incrBy) {  
  
        return cacheUtils.redisTemplate.execute((RedisCallback<Double>) connection -> {  
  
            returnconnection.incrBy(key.getBytes(), incrBy); }); } /** * Determine whether the data is cached ** @param key * data key * @return*/ public static Boolean isCached(String key) {return cacheUtils.redisTemplate.execute((RedisCallback<Boolean>) connection -> {  
            returnconnection.exists(key.getBytes()); }); } /** * judgehashWhether data is cached in the collection * * @param hName * @param key * data key * @return*/ public static BooleanhashCached(String hName, String key) {  
  
        return cacheUtils.redisTemplate.execute((RedisCallback<Boolean>) connection -> {  
            returnconnection.hExists(key.getBytes(), key.getBytes()); }); } /** * determine whether the cache is cached in the specified collection ** @param key * @param val * data * @return*/ public static Boolean isMember(String key, String val) {return cacheUtils.redisTemplate.execute((RedisCallback<Boolean>) connection -> {  
            returnconnection.sIsMember(key.getBytes(), val.getBytes()); }); } /** * delete data from the cache ** @param string * @return*/ public static void delKey(String key) { cacheUtils.redisTemplate.execute((RedisCallback<Long>) connection -> connection.del(key.getBytes())); } /** * set timeout ** @param key * @param seconds */ public static void expire(String key) int seconds) { cacheUtils.redisTemplate .execute((RedisCallback<Boolean>) connection -> connection.expire(key.getBytes(), seconds)); } /** * is listedsetAll members * * @paramsetName 
     *            setName * @return 
     */  
    public static Set<Object> listSet(String setName) {  
  
        return cacheUtils.redisTemplate.opsForHash().keys(setName); } / * * *setTo append a value * * @paramsetName 
     *            setName * @param value */ public static voidsetSave(String setName, String value) {  
  
        cacheUtils.redisTemplate  
                .execute((RedisCallback<Long>) connection -> connection.sAdd(setName.getBytes(), value.getBytes())); } /** * lists sorted in reverse ordersetfractionalsetList * * @param key *setName * @param start * start position * @param end * end position * @returnPublic static Set<Tuple> listSortedsetRev(String key, int start, int end) {public static Set<Tuple> listSortedsetRev(String key, int start, int end) {return cacheUtils.redisTemplate.execute((RedisCallback<Set<Tuple>>) connection -> {  
            returnconnection.zRevRangeWithScores(key.getBytes(), start, end); }); } /** * get sorted sort ** @param key *setName * @param member * @return*/ public static Long getRankRev(String key, String member) {return cacheUtils.redisTemplate.execute((RedisCallback<Long>) connection -> {  
            returnconnection.zRevRank(key.getBytes(), member.getBytes()); }); } /** * get sorted sort score by member name ** @param key *setName * @param member * @returnPublic static Double memberScore (String key, String member) {public static Double memberScore (String key, String member) {return cacheUtils.redisTemplate.execute((RedisCallback<Double>) connection -> {  
            returnconnection.zScore(key.getBytes(), member.getBytes()); }); } /** * get sortedsetTo append a value * * @param key *setPublic static void saveToSortedset(String key, Double score, String member) { cacheUtils.redisTemplate.execute( (RedisCallback<Boolean>) connection -> connection.zAdd(key.getBytes(), score, member.getBytes())); } /** * from sortedsetDelete a value * * @param key *set@param member */ public static void delFromSortedset(String key) String member) { cacheUtils.redisTemplate .execute((RedisCallback<Long>) connection -> connection.zRem(key.getBytes(), member.getBytes())); } / * * * fromhashPublic static <T> T getBeanFromMap(String key, String key, String key) String field, Class<T> clazz) { byte[] input = cacheUtils.redisTemplate.execute((RedisCallback<byte[]>) connection -> {return connection.hGet(key.getBytes(), field.getBytes());  
        });  
        returnJSON.parseObject(input, clazz, Feature.AutoCloseSource); } public static void delFromMap(String key, String key, String key, String key, String key) String field) { cacheUtils.redisTemplate .execute((RedisCallback<Long>) connection -> connection.hDel(key.getBytes(), field.getBytes())); } /** ** @description: Grows by key, counter * @author CLG * @date June 30, 2016 2:37:52 PM ** @param key * @return 
     */  
    public static long incr(String key) {  
  
        return cacheUtils.redisTemplate.execute((RedisCallback<Long>) connection -> {  
            returnconnection.incr(key.getBytes()); }); } /** ** @description: Obtain the current count result by key * @author CLG * @date June 30, 2016 2:38:20 PM ** @param key * @return 
     */  
    public static String getCount(String key) {  
  
        returncacheUtils.redisTemplate.opsForValue().get(key); } /** * inserts all specified values to the head of the list stored in key. If the key does not exist, an empty list is created * * @param <T> * * @param key * @param value * @ before the push operationreturn 
     */  
    public static <T> Long lpush(String key, T value) {  
  
        returncacheUtils.redisTemplate.opsForList().leftPush(key, JSON.toJSONString(value)); } /** * Insert value in the list header below the key only if the key already exists and a list exists. In contrast to LPUSH, nothing is done when the * key does not exist * * @param key * @param value * @return 
     */  
    public static <T> Long lpushx(String key, T value) {  
  
        returncacheUtils.redisTemplate.opsForList().leftPushIfPresent(key, JSON.toJSONString(value)); } /** * returns the length of the list stored in the key. If the key does not exist, it is considered an empty list and returns a length of 0 * * @param key * @return 
     */  
    public static Long llen(String key) {  
  
        returncacheUtils.redisTemplate.opsForList().size(key); } /** * returns the elements stored in the list of keys in the specified range. The start and end * offsets are based on the index 0, that is, the first element of the list is indexed 0 (the list header), the second element is indexed 1, and so on * * @param key * @return 
     */  
    public static List<String> lrange(String key, long start, long end) {  
  
        returncacheUtils.redisTemplate.opsForList().range(key, start, end); } /** * removes and returns the first element of the list ** @param key * @return 
     */  
    public static String lpop(String key) {  
  
        returncacheUtils.redisTemplate.opsForList().leftPop(key); } /** * save tohashCollection sets the value of a field only if the specified field does not exist in the hash set specified by key. If the hash set specified by key does not exist, a new hash set is created and associated with * key. If the field already exists, the operation has no effect. Public static void hsetnx(String hName, String key, String value) { cacheUtils.redisTemplate.execute((RedisCallback<Boolean>) connection -> connection.hSetNX(key.getBytes(), key.getBytes(), value.getBytes())); } /** * save tohashCollection sets the value of a field only if the specified field does not exist in the hash set specified by key. If the hash set specified by key does not exist, a new hash set is created and associated with * key. If the field already exists, the operation has no effect. Public static <T> void hsetnx(String hName, String hName, String hName) String key, T t) { hsetnx(hName, key, JSON.toJSONString(t)); }}Copy the code

2, the key comes, how do we call our JAR package to add self-start? First add autoconfig

package com.ecej.nove.redis.core;  
  
import org.springframework.context.annotation.Configuration;  
import org.springframework.context.annotation.Import;  
  
import com.ecej.nove.redis.config.RedisClusterConfig;  
import com.ecej.nove.redis.config.RedisSentinelConfig;  
import com.ecej.nove.redis.utils.JedisClusterUtils;  
  
@Configuration  
@Import({ RedisClusterConfig.class, RedisSentinelConfig.class, JedisClusterUtils.class })  
public class RedisAutoConfiguration {  
  
}  
Copy the code

Add meta-INF/spring.Factories to the bootstrap scan configuration under SRC \main\resources

Auto Configure

org.springframework.boot.autoconfigure.EnableAutoConfiguration=

com.ecej.nove.redis.core.RedisAutoConfiguration

If you want to use Redis in your own project, first add dependency com.nove xxx-redis

There are two types of redis clusters: sentinel and 3.x clusters. Choose your cluster configuration according to your needs. The configuration files are all in the resources section. Using com. XXX. Nove. Redis. Utils. JedisClusterUtils the static class remote – redis. The properties of this you can directly download to use [email protected]@ [email protected]@ Xxx.redis. [email protected]@ You can optionally add XXX.redis. [email protected]@ to the following configuration [email protected]@ [email protected]@

This is the configuration of properties. Now let’s talk about the configuration of profiles in POM < XXX. Redis. The hostName > 10.32.32.58:26379,10.32. 32.58:26380,10.32. 32.58:26381 < / XXX. Redis. The hostName > <xxx.redis.mastername>redismaster</xxx.redis.mastername> <xxx.redis.password></xxx.redis.password> <xxx.redis.maxIdle>10</xxx.redis.maxIdle> <xxx.redis.maxTotal>1000</xxx.redis.maxTotal> <xxx.redis.maxWaitMillis>3000</xxx.redis.maxWaitMillis>

Properties [email protected] @xxx.redis.hostName [email protected]@ MaxIdle [email protected]. MaxIdle @xxx.redis. MaxTotal = @XXX.redis [email protected]@ [email protected]@

The profile configuration < xxx.redis.hostname >10.4.89.161:6379</ xxx.redis.hostname > is posted below <xxx.redis.maxRedirects>10</xxx.redis.maxRedirects> <xxx.redis.password></xxx.redis.password> <xxx.redis.maxIdle>10</xxx.redis.maxIdle> <xxx.redis.maxTotal>1000</xxx.redis.maxTotal> <xxx.redis. MaxWaitMillis >3000</xxx.redis. MaxWaitMillis > Xcluster =true xcluster =true xcluster =true xcluster =true xcluster =true Choose one of these configurations and place it in application.properties.

OK, all configuration is complete, you can use happily


Follow the public account, will get the latest article push