From 16da379b8a6335079e144a8062b1aac729704d80 Mon Sep 17 00:00:00 2001 From: sim-wangyan <8966188@qq.com> Date: Tue, 8 Nov 2022 16:10:16 +0800 Subject: [PATCH] Add builder API: InRequired (#55) --- .../internal/DefaultL2CacheResolver.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/sqli-core/src/main/java/io/xream/sqli/cache/internal/DefaultL2CacheResolver.java b/sqli-core/src/main/java/io/xream/sqli/cache/internal/DefaultL2CacheResolver.java index 0f3ec9a6..41eaa2e2 100644 --- a/sqli-core/src/main/java/io/xream/sqli/cache/internal/DefaultL2CacheResolver.java +++ b/sqli-core/src/main/java/io/xream/sqli/cache/internal/DefaultL2CacheResolver.java @@ -185,14 +185,14 @@ public void remove(Class clz) { private String getNSKeyReadable(Class clz){ if (getFilterFactor() == null) - return clz.getName()+ NANO_SECOND; - String str = clz.getName() + NANO_SECOND + getFilterFactor(); + return clz.getSimpleName()+ NANO_SECOND; + String str = clz.getSimpleName() + NANO_SECOND + getFilterFactor(); return str; } @SuppressWarnings("rawtypes") private String getNSKey(Class clz){ - return clz.getName()+ NANO_SECOND; + return clz.getSimpleName()+ NANO_SECOND; } private String getNSReadable(Class clzz){ @@ -224,43 +224,42 @@ private List getKeyList(Class clz, List conditionSet){ } /** - * FIXME 有简单simpleKey的地方全改成字符串存储, value为bytes, new String(bytes) * @param clz * @param condition * @return */ @SuppressWarnings("rawtypes") private String getSimpleKey(Class clz, String condition){ - return "{"+clz.getName()+"}." + condition; + return "{"+clz.getSimpleName()+"}:" + condition; } private String getTotalRowsKey(Class clz, String condition){ condition = MD5Helper.toMD5(condition) + "~TR"; - return "{"+clz.getName()+"}." + getNSReadable(clz) + "." + condition; + return "{"+clz.getSimpleName()+"}:" + getNSReadable(clz) + "." + condition; } private String getConditionedKey(Class clz, String condition){ condition = MD5Helper.toMD5(condition) + "~C"; - return "{"+clz.getName()+"}." + getNSReadable(clz) + condition; + return "{"+clz.getSimpleName()+"}:" + getNSReadable(clz) + condition; } private String getSimpleKeyLike(Class clz){ - return "{"+clz.getName()+"}.*" ; + return "{"+clz.getSimpleName()+"}:*" ; } private String getKeyForOneObject(Class clz, Object condition){ if (condition == null) throw new L2CacheException("getKeyForOneObject, id = " + condition); - return getPrefixForOneObject(clz) +"."+MD5Helper.toMD5(""+condition); + return getPrefixForOneObject(clz) +":"+MD5Helper.toMD5(""+condition); } private String getPrefixForOneObject(Class clz){ String nsStr = getNSReadable(clz); if (nsStr == null){ String str = markForRefresh0(clz); - return "{"+clz.getName()+"}." + str; + return "{"+clz.getSimpleName()+"}:" + str; } - return "{"+clz.getName()+"}." + nsStr; + return "{"+clz.getSimpleName()+"}:" + nsStr; } private void setTotalRows(Class clz, String cacheKey, long obj) {