whycxzp
2025-05-07 5fc6392ea5c1e6b74751d8cb9ebabe10f18c6002
本地缓存增加
5个文件已修改
1个文件已删除
1个文件已添加
127 ■■■■ 已修改文件
pom.xml 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/config/CacheConfig.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/config/CaffeineConfig.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/UserBridgeService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/UserService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/config/application-dev.yml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/config/application-prod.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml
@@ -51,12 +51,6 @@
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <!--highgo数据库连接池 安全版V4.5版本及企业版V6兼容-->
        <dependency>
            <groupId>com.highgo</groupId>
            <artifactId>HgdbJdbc</artifactId>
            <version>6.2.3</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
@@ -136,6 +130,10 @@
            <version>3.0.4</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-cache</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.ben-manes.caffeine</groupId>
            <artifactId>caffeine</artifactId>
        </dependency>
src/main/java/com/whyc/config/CacheConfig.java
New file
@@ -0,0 +1,9 @@
package com.whyc.config;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableCaching
public class CacheConfig {
}
src/main/java/com/whyc/config/CaffeineConfig.java
File was deleted
src/main/java/com/whyc/service/UserBridgeService.java
@@ -19,14 +19,13 @@
@Service
//Unified Naming
//@CacheConfig(cacheNames ={"userBridge"})
@DependsOn("caffeineCacheManager")
public class UserBridgeService {
    @Resource
    private UserMapper userMapper;
    @Resource
    private CacheManager caffeineCacheManager;
    private CacheManager cacheManager;
    public User findPasswordByUserName(String name) {
        User user = null;
src/main/java/com/whyc/service/UserService.java
@@ -11,6 +11,9 @@
import com.whyc.util.RSAUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
@@ -61,6 +64,8 @@
            return new Response<>().set(0);
        }
    }
    @CacheEvict(value = "userPage",allEntries = true)
    public Response addByRSA(User user) {
        User userFound = userBridgeService.findPasswordByUserName(user.getName());
        if (userFound.getId() != 0) {
@@ -124,6 +129,7 @@
        return users;
    }
    @Cacheable(value = "userPage")
    public Response getPage(int pageNum,int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> list = userMapper.selectList((Wrapper<User>) CommonUtil.objectNull);
@@ -134,6 +140,7 @@
        return new Response().set(1,pageInfo,"查询成功");
    }
    @CacheEvict(value = "userPage",allEntries = true)
    public Response update(User user) {
        User userFound = userBridgeService.findPasswordByUserName(user.getName());
        User userOfPhoneNumber = userBridgeService.getUserByPhoneNumber(user.getPhoneNumber());
src/main/resources/config/application-dev.yml
@@ -43,6 +43,11 @@
    username: whyc_doc@163.com
    password: JAMKMEQUOAGGMSVV
    default-encoding: UTF-8
  cache:
    type: caffeine
    caffeine:
      spec: maximumSize=100,expireAfterWrite=30m
jasypt:
  encryptor:
    #password: 9Lu6HgEvttjj8vYhy3ID+PqPbumuXhcH
src/main/resources/config/application-prod.yml
@@ -40,6 +40,10 @@
    username: whyc_doc@163.com
    password: JAMKMEQUOAGGMSVV
    default-encoding: UTF-8
  cache:
    type: caffeine
    caffeine:
      spec: maximumSize=100,expireAfterWrite=30m
jasypt:
  encryptor:
    algorithm: PBEWithMD5AndDES