Skip to content

Commit

Permalink
Add builder API: InRequired (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
sim-wangyan committed Nov 8, 2022
1 parent 61c7c3c commit 16da379
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -224,43 +224,42 @@ private List<String> getKeyList(Class clz, List<String> 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) {
Expand Down

0 comments on commit 16da379

Please sign in to comment.