Skip to content

Commit

Permalink
修复了redis批量获取时候,不同group相同key,导致数据覆盖问题
Browse files Browse the repository at this point in the history
  • Loading branch information
junxworks committed Jul 20, 2018
1 parent 1af014e commit d3fc70a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion junx-cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<version>1.0.1</version>
</parent>
<artifactId>junx-cache</artifactId>
<version>1.0.3.3</version>
<version>1.0.3.4</version>
<dependencies>
<dependency>
<groupId>io.github.junxworks</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void setValue(Object _value) {
public boolean equals(Object obj) {
if (obj != null && (obj instanceof KV)) {
KV kv = (KV) obj;
return _equals(group, kv.group) && _equals(key, kv.key);
return _equals(group, kv.group) && _equals(key, kv.key) && _equals(separator, kv.separator);
}
return false;
}
Expand Down Expand Up @@ -229,6 +229,6 @@ public void setUseTTL(boolean useTTL) {
*/
@Override
public int hashCode() {
return Objects.hashCode(group, key);
return Objects.hashCode(group, key, separator);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ public List<KV> get(List<KV> kvs) {
KV kv = null;
for (int i = 0, len = kvs.size(); i < len; i++) {
kv = kvs.get(i);
String key = kv.getKey();
String key = getComposedKey(kv);
if (!newMap.containsKey(key)) {
newMap.put(key, p.get(getComposedKeyBytes(kv)));
}
}
p.sync();
for (int i = 0; i < kvs.size(); i++) {
kvs.get(i).setValue(newMap.get(kvs.get(i).getKey()).get());
kvs.get(i).setValue(newMap.get(getComposedKey(kvs.get(i))).get());
}
}
return kvs;
Expand Down Expand Up @@ -123,7 +123,7 @@ public void set(List<KV> kvs) {
KV kv = null;
for (int i = 0, len = kvs.size(); i < len; i++) {
kv = kvs.get(i);
String _key = kv.getKey();
String _key = getComposedKey(kv);
if (!filter.contains(_key)) {
byte[] value = kv.getValue();
if (value == null) {
Expand Down Expand Up @@ -185,12 +185,12 @@ public Map<KV, Boolean> exists(List<KV> kvs) {
KV kv = null;
for (int i = 0, len = kvs.size(); i < len; i++) {
kv = kvs.get(i);
newMap.put(kv.getKey(), p.exists(getComposedKeyBytes(kv)));
newMap.put(getComposedKey(kv), p.exists(getComposedKeyBytes(kv)));
}
p.sync();
for (int i = 0; i < kvs.size(); i++) {
kv = kvs.get(i);
resMap.put(kv, newMap.get(kv.getKey()).get());
resMap.put(kv, newMap.get(getComposedKey(kv)).get());
}
}
return resMap;
Expand Down

0 comments on commit d3fc70a

Please sign in to comment.