From 41d4175d23dd89766dfa85161d5d7a617cbbcab7 Mon Sep 17 00:00:00 2001 From: DongZeLiang <2746733890@qq.com> Date: Sat, 30 Mar 2024 10:53:47 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96hash=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- muyu-common/muyu-common-cache/.gitignore | 38 +++++ .../muyu/common/cache/abs/HashCacheAbs.java | 130 ++++++++++++++++++ .../muyu-product-cache/.gitignore | 38 +++++ .../muyu/product/cache/ProjectInfoCache.java | 1 + muyu-modules/muyu-product/结构 | 26 ++++ 5 files changed, 233 insertions(+) create mode 100644 muyu-common/muyu-common-cache/.gitignore create mode 100644 muyu-modules/muyu-product/muyu-product-cache/.gitignore create mode 100644 muyu-modules/muyu-product/结构 diff --git a/muyu-common/muyu-common-cache/.gitignore b/muyu-common/muyu-common-cache/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/muyu-common/muyu-common-cache/.gitignore @@ -0,0 +1,38 @@ +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 \ No newline at end of file diff --git a/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/abs/HashCacheAbs.java b/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/abs/HashCacheAbs.java index 0f3cec8..05b70dd 100644 --- a/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/abs/HashCacheAbs.java +++ b/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/abs/HashCacheAbs.java @@ -2,10 +2,140 @@ package com.muyu.common.cache.abs; import com.muyu.common.cache.HashCache; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + /** * @author DongZl * @description: hash缓存抽象类 * @Date 2024-3-29 下午 07:40 */ public abstract class HashCacheAbs implements HashCache { + + /** + * 编码 + * + * @param key ID + * + * @return 键 + */ + @Override + public String encode (K key) { + return keyPre() + key; + } + + /** + * 编码 + * @param hashKey ID + * @return 键 + */ + @Override + public String encodeHashKey (HK hashKey) { + return hashKey.toString(); + } + + /** + * 通过Key获取所有的map + * @param key 数据库键 + * @return 所有集合Map + */ + @Override + public Map get (K key) { + return null; + } + + /** + * 通过键和hashKey获取数据库hashValue + * + * @param key 键 + * @param hashKey hash键 + * + * @return hash值 + */ + @Override + public HV get (K key, HK hashKey) { + return null; + } + + /** + * 通过键和hashKey获取数据库hashValue + * + * @param key 键 + * @param hashKeyList hash键集合 + * + * @return hash值 + */ + @Override + public HV get (K key, HK... hashKeyList) { + return null; + } + + /** + * 获取hash值集合 + * + * @param key 键 + * + * @return hash值集合 + */ + @Override + public List getToList (K key) { + return null; + } + + /** + * 存储数据 + * + * @param key redis键 + * @param map hashMap集合 + */ + @Override + public void put (K key, Map map) { + + } + + /** + * 存储数据 + * + * @param key redis键 + * @param dataList 数据值 + * @param hashKey hash键 + */ + @Override + public void put (K key, List dataList, Function hashKey) { + + } + + /** + * 存储数据 + * + * @param key redis键 + * @param hashKey hash键 + * @param hashValue hash值 + */ + @Override + public void put (K key, HK hashKey, HV hashValue) { + + } + + /** + * 通过redis键删除 + * + * @param key hash键 + */ + @Override + public void remove (K key) { + + } + + /** + * 通过redis键和hash键删除 + * + * @param key redis键 + * @param hashKey hash键 + */ + @Override + public void remove (K key, HK hashKey) { + + } } diff --git a/muyu-modules/muyu-product/muyu-product-cache/.gitignore b/muyu-modules/muyu-product/muyu-product-cache/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/muyu-modules/muyu-product/muyu-product-cache/.gitignore @@ -0,0 +1,38 @@ +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 \ No newline at end of file diff --git a/muyu-modules/muyu-product/muyu-product-cache/src/main/java/com/muyu/product/cache/ProjectInfoCache.java b/muyu-modules/muyu-product/muyu-product-cache/src/main/java/com/muyu/product/cache/ProjectInfoCache.java index b5c10f0..0ffdd17 100644 --- a/muyu-modules/muyu-product/muyu-product-cache/src/main/java/com/muyu/product/cache/ProjectInfoCache.java +++ b/muyu-modules/muyu-product/muyu-product-cache/src/main/java/com/muyu/product/cache/ProjectInfoCache.java @@ -35,6 +35,7 @@ public class ProjectInfoCache extends CacheAbs { @Autowired private ProjectInfoData projectInfoData; + /** * key前缀 * diff --git a/muyu-modules/muyu-product/结构 b/muyu-modules/muyu-product/结构 new file mode 100644 index 0000000..f4f14d7 --- /dev/null +++ b/muyu-modules/muyu-product/结构 @@ -0,0 +1,26 @@ +{ 基本信息: { + name: "", + introduction: "", + mianType: "", + parentType: "", + type: "", + image: "", + carouselImages: "", + status: "", + ruleId: "", + branId: "", + remark: "" + }, + 品类属性: [ { + id: "", + value: "", + } ………… + ], + 商品规格: [ { + SKU: "",(所有的规格属性拼接而成) + "images": "", + 库存: "", + 价格: "", + } ………… + ] +} From e1d039804c0e797f0900d38e8f9ff7cf782cfade Mon Sep 17 00:00:00 2001 From: DongZeLiang <2746733890@qq.com> Date: Sat, 30 Mar 2024 11:16:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96hash=E7=BC=93?= =?UTF-8?q?=E5=AD=98-get?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/muyu/common/cache/HashCache.java | 2 +- .../java/com/muyu/common/cache/abs/HashCacheAbs.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/HashCache.java b/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/HashCache.java index b2dceff..20bf7cc 100644 --- a/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/HashCache.java +++ b/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/HashCache.java @@ -26,7 +26,7 @@ public interface HashCache extends DecorationKey { * @param redisHashKey 数据库键 * @return ID */ - public K decodeHashKey(String redisHashKey); + public HK decodeHashKey(String redisHashKey); /** * 通过Key获取所有的map diff --git a/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/abs/HashCacheAbs.java b/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/abs/HashCacheAbs.java index 05b70dd..ff4fe58 100644 --- a/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/abs/HashCacheAbs.java +++ b/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/abs/HashCacheAbs.java @@ -1,7 +1,10 @@ package com.muyu.common.cache.abs; import com.muyu.common.cache.HashCache; +import com.muyu.common.redis.service.RedisService; +import org.springframework.beans.factory.annotation.Autowired; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Function; @@ -13,6 +16,9 @@ import java.util.function.Function; */ public abstract class HashCacheAbs implements HashCache { + @Autowired + private RedisService redisService; + /** * 编码 * @@ -42,7 +48,10 @@ public abstract class HashCacheAbs implements HashCache { */ @Override public Map get (K key) { - return null; + Map dataMap = redisService.getCacheMap(encode(key)); + Map resultMap = new HashMap<>(); + dataMap.forEach((hashKey, hashValue) -> resultMap.put(decodeHashKey(hashKey), hashValue)); + return resultMap; } /** From 2bc592c87e4600c6d53dd871050c20e4f68de954 Mon Sep 17 00:00:00 2001 From: DongZeLiang <2746733890@qq.com> Date: Sat, 30 Mar 2024 11:19:52 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96hash=E7=BC=93?= =?UTF-8?q?=E5=AD=98-get?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/muyu/common/cache/abs/HashCacheAbs.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/abs/HashCacheAbs.java b/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/abs/HashCacheAbs.java index ff4fe58..2793eec 100644 --- a/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/abs/HashCacheAbs.java +++ b/muyu-common/muyu-common-cache/src/main/java/com/muyu/common/cache/abs/HashCacheAbs.java @@ -64,7 +64,7 @@ public abstract class HashCacheAbs implements HashCache { */ @Override public HV get (K key, HK hashKey) { - return null; + return redisService.getCacheMapValue(encode(key), encodeHashKey(hashKey)); } /**