xml 春天缓存哨兵

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml 春天缓存哨兵相关的知识,希望对你有一定的参考价值。

spring.redis.sentinel.master=mymaster
spring.redis.sentinel.nodes=192.168.10.107:26379,192.168.10.107:26380,192.168.10.107:26381
spring.redis.jedis.pool.max-active=100
spring.redis.jedis.pool.max-wait=1000ms
spring.redis.jedis.pool.max-idle=100
spring.redis.password=main
package com.finshope.springbootsentinel.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext;

@Configuration
public class RedisConfig {

    @Bean
    public RedisCacheConfiguration redisCacheConfiguration(RedisConnectionFactory factory) {
        RedisCacheConfiguration configuration = RedisCacheConfiguration.defaultCacheConfig();
        configuration = configuration.serializeValuesWith(RedisSerializationContext.SerializationPair.
                fromSerializer(new GenericJackson2JsonRedisSerializer()));
        return configuration;

    }
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.finshope</groupId>
    <artifactId>springbootsentinel</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springbootsentinel</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-cache</artifactId>
            <version>2.1.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.9</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

以上是关于xml 春天缓存哨兵的主要内容,如果未能解决你的问题,请参考以下文章

java 春天全局缓存

redis主从复制,哨兵机制,缓存穿透缓存击穿缓存雪崩

第128天学习打卡(Redis 哨兵模式 Redis缓存穿透和缓存击穿 雪崩)

Redis----常见重点知识2(主从复制哨兵机制缓存穿透和雪崩)

Redis----常见重点知识2(主从复制哨兵机制缓存穿透和雪崩)

缓存加速------Redis主从复制,哨兵模式,集群