springboot redis

配置redis
docker安裝redis教程很多 再用到的時候自己搜一下吧
pom:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
application.properties:
#=========redis基礎配置=========
spring.redis.database=0
spring.redis.host=127.0.0.1
spring.redis.port=6390
#連接超時時間 單位 ms(毫秒)
spring.redis.timeout=3000

        #=========redis線程池設置=========
        #連接池中的最大空閒連接,默認值也是8。
        spring.redis.pool.max-idle=200

        #連接池中的最小空閒連接,默認值也是0。
        spring.redis.pool.min-idle=200

        #如果賦值爲-1,則表示不限制;pool已經分配了maxActive個jedis實例,則此時pool的狀態爲exhausted(耗盡)。
        spring.redis.pool.max-active=2000

        #等待可用連接的最大時間,單位毫秒,默認值爲-1,表示永不超時
        spring.redis.pool.max-wait=1000

工具類:br/>@Resource
private StringRedisTemplate stringRedisTemplate;
RedisTemplate中定義了5種數據結構操作
redisTemplate.opsForValue();  //操作字符串
redisTemplate.opsForHash();   //操作hash
redisTemplate.opsForList();   //操作list
redisTemplate.opsForSet();   //操作set
redisTemplate.opsForZSet();   //操作有序set
主要學習了opsForList的一些用法。range是取值 不影響集合,leftpop rightpop是彈出值
外網訪問配置:
protected-mode no

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章