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
1-1. Problem solving
cache optimization
Environment build
maven coordinates
configuration file
configuration class
@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
Implementation ideas
code modification
function test
Cache dish data
Spring Cache
Introduction to Spring Cache
Spring Cache common annotations
How to use Spring Cache
Cache package data
Implementation ideas
code modification
2. Problem
2-2 Problem Solving
read-write separation
Mysql master-slave replication
introduce
configuration
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)
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
The project achieves read-write separation