最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯網營銷解決方案
springbootredis

dependency

成都創(chuàng)新互聯公司-專業(yè)網站定制、快速模板網站建設、高性價比博樂網站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式博樂網站制作公司更省心,省錢,快速模板網站建設找我們,業(yè)務覆蓋博樂地區(qū)。費用合理售后完善,十余年實體公司更值得信賴。

        
            org.springframework.boot
            spring-boot-starter-data-redis
        
        
            org.apache.commons
            commons-pool2
        

application-redis.properties

#########基礎配置#########
spring.redis.database=0
#spring.redis.url=redis://user:[email protected]:6379
spring.redis.host=
spring.redis.port=
spring.redis.password=
spring.redis.timeout=30000
spring.redis.ssl=false

#########redis哨兵設置#########
#spring.redis.sentinel.master=
#spring.redis.sentinel.nodes=
#spring.redis.cluster.max-redirects=
#spring.redis.cluster.nodes=

#########jedis client 線程池配置#########
#spring.redis.jedis.pool.max-active=
#spring.redis.jedis.pool.max-idle=
#spring.redis.jedis.pool.min-idle=
#spring.redis.jedis.pool.max-wait=

#########lettuce client 線程池配置(默認)#########
spring.redis.lettuce.pool.max-active=10
spring.redis.lettuce.pool.max-idle=5
spring.redis.lettuce.pool.min-idle=1
spring.redis.lettuce.pool.max-wait=20000
spring.redis.lettuce.shutdown-timeout=10

Test

@RunWith(SpringRunner.class)
@SpringBootTest
public class AnnotationAppContextTest {
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Test
    public void setTest(){
        redisTemplate.opsForValue().set("key1","val1", 100);
        String key1 = redisTemplate.opsForValue().get("key1");
        System.err.println("=============="+key1);
    }
}

源碼-RedisProperties

@ConfigurationProperties(prefix = "spring.redis")
public class RedisProperties {

    /**
     * Database index used by the connection factory.
     */
    private int database = 0;

    /**
     * Connection URL. Overrides host, port, and password. User is ignored. Example:
     * redis://user:[email protected]:6379
     */
    private String url;

    /**
     * Redis server host.
     */
    private String host = "localhost";

    /**
     * Login password of the redis server.
     */
    private String password;

    /**
     * Redis server port.
     */
    private int port = 6379;

    /**
     * Whether to enable SSL support.
     */
    private boolean ssl;

    /**
     * Connection timeout.
     */
    private Duration timeout;

    private Sentinel sentinel;

    private Cluster cluster;

    private final Jedis jedis = new Jedis();

    private final Lettuce lettuce = new Lettuce();
}   

源碼-RedisAutoConfiguration

@Configuration
@ConditionalOnClass(RedisOperations.class)
@EnableConfigurationProperties(RedisProperties.class)
@Import({ LettuceConnectionConfiguration.class, JedisConnectionConfiguration.class })
public class RedisAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(name = "redisTemplate")
    public RedisTemplate redisTemplate(
            RedisConnectionFactory redisConnectionFactory) throws UnknownHostException {
        RedisTemplate template = new RedisTemplate<>();
        template.setConnectionFactory(redisConnectionFactory);
        return template;
    }

    @Bean
    @ConditionalOnMissingBean(StringRedisTemplate.class)
    public StringRedisTemplate stringRedisTemplate(
            RedisConnectionFactory redisConnectionFactory) throws UnknownHostException {
        StringRedisTemplate template = new StringRedisTemplate();
        template.setConnectionFactory(redisConnectionFactory);
        return template;
    }

}

參考:https://blog.csdn.net/abombhz/article/details/78123253?locationNum=6&fps=1


網站欄目:springbootredis
網頁地址:http://fisionsoft.com.cn/article/psocgg.html