Project - St. Regis takeaway project optimization (5)

Regis project optimization

1. Problem

A large number of users, a large amount of system access, frequent access to the database, system performance degradation, and poor user experience

insert image description here

1-1. Problem solving

cache optimization
insert image description here

Environment build

insert image description here

maven coordinates

insert image description here

configuration file

insert image description here

configuration class

insert image description here

@Configuration
public class RedisConfig extends CachingConfigurerSupport {
    @Bean
    public RedisTemplate<Object,Object> redisTemplate(RedisConnectionFactory connectionFactory){
        RedisTemplate<Object ,Object> redisTemplate = new RedisTemplate<>();
        redisTemplate.setKeySerializer(new StringRedisSerializer());
        redisTemplate.setConnectionFactory(connectionFactory);
        return redisTemplate;
    }
}

Cache SMS verification code

insert image description here

Implementation ideas

insert image description here

code modification

function test

Cache dish data

insert image description here

Spring Cache

insert image description here

Introduction to Spring Cache

insert image description here

Spring Cache common annotations

insert image description here

How to use Spring Cache

insert image description here

Cache package data

insert image description here

Implementation ideas

insert image description here

code modification

insert image description here

insert image description here

insert image description here

2. Problem

insert image description here

2-2 Problem Solving

read-write separation

insert image description here

Mysql master-slave replication

insert image description here

introduce

insert image description here

configuration

insert image description here

insert image description here

insert image description here
insert image description here

mysql> create user chunlei identified by 'Root@123456';
Query OK, 0 rows affected (0.02 sec)

mysql> GRANT REPLICATION SLAVE ON *.* TO 'chunlei'@'%';
Query OK, 0 rows affected (0.01 sec)

insert image description here

mysql> show master status;
±-----------------±---------±-------------±-----------------±------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
±-----------------±---------±-------------±-----------------±------------------+
| mysql-bin.000001 | 695 | | | |
±-----------------±---------±-------------±-----------------±------------------+
1 row in set (0.00 sec)

test

Read and write separation case

insert image description here

insert image description here

The project achieves read-write separation

insert image description here
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/weixin_45428910/article/details/130819077