redis性能优化

秒速:单台redis内存容量是无限的.然而如果有海量的数据要求实现缓存存储,则应该应用多个Redis节点.

Redis分片机制定义:

Redis分片机制配置

配置布局
配置形容:筹备3台redis服务器,端口号别离为6379/6380/6381

1.筹备3个配置文件

2.别离批改端口号:

3.启动redis服务器

4.查看redis启动状态

5.案例测试

6.依据redis节点个数.拼接字符串

7.编辑RedisConfig配置类
@Configuration //标识我是一个配置类 个别与@Bean注解联用
@PropertySource("classpath:/properties/redis.properties")
public class RedisConfig {

@Value("${redis.nodes}")private String nodes;   //node,node,node@Beanpublic ShardedJedis shardedJedis(){    List<JedisShardInfo> shards = new ArrayList<>();    String[] nodeArray = nodes.split(",");    for( String node :nodeArray){  //node=host:port        String host = node.split(":")[0];        int port = Integer.parseInt(node.split(":")[1]);        JedisShardInfo info = new JedisShardInfo(host,port);        shards.add(info);    }    return new ShardedJedis(shards);}}

8.批改CacheAOP中的注入