feat():添加缓存模块封装方法
parent
93f78cdc3e
commit
efd7a46c68
|
@ -0,0 +1,33 @@
|
|||
<?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>com.muyu</groupId>
|
||||
<artifactId>cloud-server</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<description>
|
||||
cloud-common-cache 缓存基准
|
||||
</description>
|
||||
|
||||
<artifactId>cloud-common- </artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>23</maven.compiler.source>
|
||||
<maven.compiler.target>23</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- redis 缓存模块-->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-redis</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,33 @@
|
|||
package com.muyu.common.cache;
|
||||
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* 抽象缓存层
|
||||
* * @className: CacheAbsBasic ️✈️
|
||||
* * @author: Yang 鹏 🦅
|
||||
* * @date: 2024/9/29 16:08 ⏰
|
||||
* * @Version: 1.0
|
||||
* * @description:
|
||||
*/
|
||||
public abstract class CacheAbsBasic <K, V> implements CacheBasic<K, V>{
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Override
|
||||
public void put(K key, V value) {
|
||||
redisService.setCacheObject(encode(key), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(K key) {
|
||||
return redisService.getCacheObject(encode(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(K key) {
|
||||
redisService.deleteObject(encode(key));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.common.cache;
|
||||
|
||||
/**
|
||||
* 缓存基础
|
||||
* * @className: CacheBasic ️✈️
|
||||
* * @author: Yang 鹏 🦅
|
||||
* * @date: 2024/9/29 16:08 ⏰
|
||||
* * @Version: 1.0
|
||||
* * @description:
|
||||
*/
|
||||
public interface CacheBasic<K,V> extends PrimaryKeyBasic<K>{
|
||||
void put(K key, V value);
|
||||
|
||||
V get(K key);
|
||||
|
||||
void remove(K key);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.muyu.common.cache;
|
||||
|
||||
/**
|
||||
* 主键基础
|
||||
* * @className: PrimaryKeyBasic ️✈️
|
||||
* * @author: Yang 鹏 🦅
|
||||
* * @date: 2024/9/29 16:08 ⏰
|
||||
* * @Version: 1.0
|
||||
* * @description:
|
||||
*/
|
||||
public interface PrimaryKeyBasic <K>{
|
||||
|
||||
/**
|
||||
* 主键前缀
|
||||
* @return
|
||||
*/
|
||||
public String keyPre();
|
||||
|
||||
/**
|
||||
* 主键编码
|
||||
* @param key 缓存建
|
||||
* @return 装修建
|
||||
*/
|
||||
public default String encode(K key){
|
||||
return keyPre() + key.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键解码
|
||||
* @param key 缓存建
|
||||
* @return 装修建
|
||||
*/
|
||||
public default K decode(String key) {
|
||||
return (K) key.substring(keyPre().length());
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -1,20 +0,0 @@
|
|||
<?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>com.muyu</groupId>
|
||||
<artifactId>cloud-modules-enterprise</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>enterpise-client</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -1,14 +0,0 @@
|
|||
package com.muyu;
|
||||
|
||||
/**
|
||||
* @Author:yan
|
||||
* @Package:com.muyu
|
||||
* @Project:Default (Template) Project
|
||||
* @name:${NAME}
|
||||
* @Date:2024/9/29 09:56
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
|
@ -22,7 +22,6 @@
|
|||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>enterpise-client</module>
|
||||
<module>enterpise-common</module>
|
||||
<module>enterpise-remote</module>
|
||||
<module>enterpise-service</module>
|
||||
|
|
10
pom.xml
10
pom.xml
|
@ -44,6 +44,7 @@
|
|||
<knife4j-openapi3.version>4.1.0</knife4j-openapi3.version>
|
||||
<xxl-job-core.version>2.4.1</xxl-job-core.version>
|
||||
<mqtt.version>1.2.5</mqtt.version>
|
||||
<mybits-plus-business>4.1.65.Final</mybits-plus-business>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
|
@ -292,6 +293,14 @@
|
|||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>${mqtt.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- mybits-plus-business 业务依赖 -->
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>${mybits-plus-business}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
@ -301,6 +310,7 @@
|
|||
<module>cloud-visual</module>
|
||||
<module>cloud-modules</module>
|
||||
<module>cloud-common</module>
|
||||
<module>cloud-common/cloud-common-cache</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
|
Loading…
Reference in New Issue