From 557fe2f459986c156e745bea2a740cf08edc1eba Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Sat, 15 Jun 2019 11:25:36 +0300 Subject: [PATCH] refactoring --- .../org/redisson/RedissonLocalCachedMap.java | 46 +--------------- .../java/org/redisson/cache/CacheValue.java | 53 +++++++++++++++++++ .../redisson/cache/LocalCacheListener.java | 1 - .../org/redisson/cache/LocalCacheView.java | 3 +- .../redisson/RedissonLocalCachedMapTest.java | 3 +- 5 files changed, 56 insertions(+), 50 deletions(-) create mode 100644 redisson/src/main/java/org/redisson/cache/CacheValue.java diff --git a/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java b/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java index f605b589a..7fd997955 100644 --- a/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java +++ b/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java @@ -16,7 +16,6 @@ package org.redisson; import java.io.IOException; -import java.io.Serializable; import java.math.BigDecimal; import java.util.AbstractMap; import java.util.ArrayList; @@ -40,6 +39,7 @@ import org.redisson.api.RLocalCachedMap; import org.redisson.api.RedissonClient; import org.redisson.cache.Cache; import org.redisson.cache.CacheKey; +import org.redisson.cache.CacheValue; import org.redisson.cache.LocalCacheListener; import org.redisson.cache.LocalCacheView; import org.redisson.cache.LocalCachedMapClear; @@ -69,50 +69,6 @@ public class RedissonLocalCachedMap extends RedissonMap implements R public static final String TOPIC_SUFFIX = "topic"; public static final String DISABLED_KEYS_SUFFIX = "disabled-keys"; public static final String DISABLED_ACK_SUFFIX = ":topic"; - - @SuppressWarnings("EqualsHashCode") - public static class CacheValue implements Serializable { - - private final Object key; - private final Object value; - - public CacheValue(Object key, Object value) { - super(); - this.key = key; - this.value = value; - } - - public Object getKey() { - return key; - } - - public Object getValue() { - return value; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CacheValue other = (CacheValue) obj; - if (value == null) { - if (other.value != null) - return false; - } else if (!value.equals(other.value)) - return false; - return true; - } - - @Override - public String toString() { - return "CacheValue [key=" + key + ", value=" + value + "]"; - } - - } private static final RedisCommand> ALL_KEYS = new RedisCommand>("EVAL", new ObjectSetReplayDecoder(), ValueType.MAP_KEY); private static final RedisCommand>> ALL_ENTRIES = new RedisCommand>>("EVAL", new ObjectMapEntryReplayDecoder(), ValueType.MAP); diff --git a/redisson/src/main/java/org/redisson/cache/CacheValue.java b/redisson/src/main/java/org/redisson/cache/CacheValue.java new file mode 100644 index 000000000..3a01ea19e --- /dev/null +++ b/redisson/src/main/java/org/redisson/cache/CacheValue.java @@ -0,0 +1,53 @@ +package org.redisson.cache; + +import java.io.Serializable; + + +/** + * + * @author Nikita Koksharov + * + */ +@SuppressWarnings("EqualsHashCode") +public class CacheValue implements Serializable { + + private final Object key; + private final Object value; + + public CacheValue(Object key, Object value) { + super(); + this.key = key; + this.value = value; + } + + public Object getKey() { + return key; + } + + public Object getValue() { + return value; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CacheValue other = (CacheValue) obj; + if (value == null) { + if (other.value != null) + return false; + } else if (!value.equals(other.value)) + return false; + return true; + } + + @Override + public String toString() { + return "CacheValue [key=" + key + ", value=" + value + "]"; + } + +} diff --git a/redisson/src/main/java/org/redisson/cache/LocalCacheListener.java b/redisson/src/main/java/org/redisson/cache/LocalCacheListener.java index 525190880..15cae611a 100644 --- a/redisson/src/main/java/org/redisson/cache/LocalCacheListener.java +++ b/redisson/src/main/java/org/redisson/cache/LocalCacheListener.java @@ -30,7 +30,6 @@ import org.redisson.RedissonListMultimapCache; import org.redisson.RedissonObject; import org.redisson.RedissonScoredSortedSet; import org.redisson.RedissonTopic; -import org.redisson.RedissonLocalCachedMap.CacheValue; import org.redisson.api.LocalCachedMapOptions; import org.redisson.api.LocalCachedMapOptions.EvictionPolicy; import org.redisson.api.LocalCachedMapOptions.ReconnectionStrategy; diff --git a/redisson/src/main/java/org/redisson/cache/LocalCacheView.java b/redisson/src/main/java/org/redisson/cache/LocalCacheView.java index 6aca477b9..276f49b77 100644 --- a/redisson/src/main/java/org/redisson/cache/LocalCacheView.java +++ b/redisson/src/main/java/org/redisson/cache/LocalCacheView.java @@ -24,9 +24,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.redisson.RedissonLocalCachedMap.CacheValue; -import org.redisson.misc.Hash; import org.redisson.RedissonObject; +import org.redisson.misc.Hash; import io.netty.buffer.ByteBuf; diff --git a/redisson/src/test/java/org/redisson/RedissonLocalCachedMapTest.java b/redisson/src/test/java/org/redisson/RedissonLocalCachedMapTest.java index 2cdcbb8e6..f31bfaab7 100644 --- a/redisson/src/test/java/org/redisson/RedissonLocalCachedMapTest.java +++ b/redisson/src/test/java/org/redisson/RedissonLocalCachedMapTest.java @@ -11,9 +11,7 @@ import java.util.concurrent.ExecutionException; import org.junit.Assert; import org.junit.Test; -import org.redisson.RedissonLocalCachedMap.CacheValue; import org.redisson.api.LocalCachedMapOptions; -import org.redisson.api.MapOptions; import org.redisson.api.LocalCachedMapOptions.EvictionPolicy; import org.redisson.api.LocalCachedMapOptions.ReconnectionStrategy; import org.redisson.api.LocalCachedMapOptions.SyncStrategy; @@ -22,6 +20,7 @@ import org.redisson.api.RLocalCachedMap; import org.redisson.api.RMap; import org.redisson.cache.Cache; import org.redisson.cache.CacheKey; +import org.redisson.cache.CacheValue; import org.redisson.client.codec.Codec; import org.redisson.client.codec.DoubleCodec; import org.redisson.client.codec.IntegerCodec;