春ブーツ集成Redisのレタス(jedis)

春のブートフレームワークはすでに1.xxのバージョンは、今デフォルトのレタスクライアントバージョン2.xxの側で使用されている場合に使用するのRedis、デフォルトのjedisクライアントを統合されています

 

依存性の導入

<! -春のブートRedisの缓存引入- > 
        <依存> 
            <groupIdを> org.springframework.boot </ groupIdを> 
            <たartifactId>春・ブート・スターター・データのRedis </たartifactId> 
            <バージョン> 2.0.4。 RELEASE </バージョン> 
        </依存関係>

  

 

プロファイル

#Redis設定
#Redisサーバーアドレス
spring.redis.host = 127.0.0.1 
#Redisサーバのポート
spring.redis.port = 6379 
#Redisサーバー接続パスワード(デフォルトでは空白)
spring.redis.password = 123456の
#Redisデータベースインデックス(デフォルトは0)である
spring.redis.database = 0 
##接続タイムアウト
spring.redis.timeout = 60秒の

接続プール次#はSpringBoot2.0における使用のために推奨されていない
##接続プールの最大接続数(負の値を使用して制限を意味しません)
#spring.redis.jedis.pool.max活性= 10 
接続プール##の最大ブロック待ち時間(負の値制限なし)
#= -1ms spring.redis.jedis.pool.max WAIT- 
##接続プール最大接続アイドル
#1 spring.redis.jedis.pool.max。8-IDLE = 
##、最小接続プールのアイドル接続
#1 spring.redis.jedis.pool.min-IDLE = 0 

#レタス
接続の#接続プールの最大数(制限なし)負の値を意味使用していない 
spring.redis.lettuce.pool.maxアクティブ8 =
#レイテンシ接続プールの最大ブロック(負の値は制限なし)
=待機-10000 spring.redis.lettuce.pool.max 
#接続プールの最大アイドル接続
spring.redis.lettuce.pool.max。8-IDLE = 
#最小接続プールアイドル接続の
spring.redis.lettuce.pool。 IDLE = 0分
#閉じるタイムアウト
= 100 spring.redis.lettuce.shutdownタイムアウト

  

 

コンフィギュレーション設定

@Configuration 
@AutoConfigureAfter(RedisConfig.class)
パブリッククラスRedisConfig { 

// @Bean 
//パブリックRedisTemplateの<string、オブジェクト> redisTemplate(RedisConnectionFactory工場){ 
// RedisTemplate <文字列、オブジェクト> redisTemplate =新しいRedisTemplate <>(); 
// redisTemplate.setKeySerializer(新StringRedisSerializer()); 
// redisTemplate.setHashKeySerializer(新StringRedisSerializer()); 
// redisTemplate.setHashValueSerializer(新StringRedisSerializer()); 
// redisTemplate.setValueSerializer(新StringRedisSerializer()); 
// redisTemplate.setConnectionFactory(工場出荷時)。
//はredisTemplateを返します。
//} 

    @Bean
    公共RedisTemplate <文字列、シリアライズ> redisCacheTemplate(LettuceConnectionFactory redisConnectionFactory){ 
        RedisTemplate <文字列、シリアライズ>テンプレート=新しいRedisTemplate <>(); 
        template.setKeySerializer(新しいStringRedisSerializer()); 
        template.setValueSerializer(新しいGenericJackson2JsonRedisSerializer()); 
        template.setConnectionFactory(redisConnectionFactory)。
        テンプレートを返します。
    } 
}

  

 

おすすめ

転載: www.cnblogs.com/achengmu/p/11345220.html