From 8068825795647dfdae52f07ca2ea3bb6137fffef Mon Sep 17 00:00:00 2001 From: likui Date: Fri, 22 Jun 2018 07:41:21 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!6=20:?= =?UTF-8?q?=20SonarQube'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 14 ---- core/pom.xml | 19 ++--- core/resources/caffeine.properties | 2 +- core/resources/ehcache.xml | 4 +- core/resources/ehcache3.xml | 2 +- core/resources/j2cache.properties | 7 +- .../src/net/oschina/j2cache/CacheChannel.java | 75 +++++++------------ core/src/net/oschina/j2cache/CacheObject.java | 14 ++-- .../net/oschina/j2cache/CacheProvider.java | 4 +- .../oschina/j2cache/CacheProviderHolder.java | 19 ++--- .../oschina/j2cache/ClusterPolicyFactory.java | 6 +- .../net/oschina/j2cache/J2CacheBuilder.java | 4 +- .../net/oschina/j2cache/J2CacheConfig.java | 10 --- core/src/net/oschina/j2cache/Level1Cache.java | 4 +- core/src/net/oschina/j2cache/Level2Cache.java | 34 ++++----- .../oschina/j2cache/MultiThreadTester.java | 22 ++---- .../j2cache/redis/RedisCacheProvider.java | 2 +- .../net/oschina/j2cache/redis/RedisUtils.java | 5 +- .../oschina/j2cache/util/FSTSerializer.java | 12 +-- .../j2cache/util/SerializationUtils.java | 2 +- modules/hibernate3/pom.xml | 4 +- modules/hibernate4/pom.xml | 4 +- modules/mybatis/pom.xml | 6 +- modules/spring-boot-starter/pom.xml | 4 +- modules/spring-boot2-starter/pom.xml | 4 +- pom.xml | 4 +- 26 files changed, 95 insertions(+), 192 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b30fd5b..364815a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,19 +1,5 @@ # J2Cache 版本更新记录 -**J2Cache 2.3.19-release (2018-5-22)** - -* 优化多线程同时读取同一个region同一个key情况下只读取一次L2数据,进一步降低redis的压力(实际100个线程测试性能提升30%左右,Redis 读取次数从 100 降低到 1) -* 可通过 `j2cache.default_cache_null_object` 配置 J2Cache 是否默认启用 null 对象缓存 - -**J2Cache 2.3.18-release (2018-5-21)** - -* 解决了使用 spring boot devtool 时 ClassCastException 异常的问题 -* 调整第三方包的依赖关系,不强制依赖,需要开发者自行加入依赖 - -**J2Cache 2.3.17-release (2018-5-16)** - -* [#IJTFT](https://gitee.com/ld/J2Cache/issues/IJTFT) 修复CacheChannel的get接口的cacheNullObject参数并不生效的问题 -* 对仓库进行重构,将扩展模块移入 modules 目录 **J2Cache 2.3.16-release (2018-5-4)** diff --git a/core/pom.xml b/core/pom.xml index 0c91349..617fda7 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -3,7 +3,7 @@ net.oschina.j2cache j2cache - 2.3.19-release + 2.3.16-release 4.0.0 @@ -15,84 +15,77 @@ com.github.ben-manes.caffeine caffeine 2.6.2 - compile redis.clients jedis 2.9.0 - compile de.ruedigermoeller fst 2.57 - compile org.slf4j slf4j-api 1.7.25 - compile org.slf4j slf4j-simple 1.7.25 - compile com.alibaba fastjson 1.2.46 - compile jline jline 2.14.2 - compile net.sf.ehcache ehcache 2.10.4 - provided + true org.ehcache ehcache 3.4.0 - provided + true org.jgroups jgroups 3.6.15.Final - provided + true com.esotericsoftware kryo-shaded 4.0.1 - provided + true org.xerial.snappy snappy-java 1.1.7.1 - provided + true diff --git a/core/resources/caffeine.properties b/core/resources/caffeine.properties index ab14474..ef35139 100644 --- a/core/resources/caffeine.properties +++ b/core/resources/caffeine.properties @@ -3,4 +3,4 @@ # [name] = size, xxxx[s|m|h|d] ######################################### -default = 1000, 30m \ No newline at end of file +default = 1000, 10s \ No newline at end of file diff --git a/core/resources/ehcache.xml b/core/resources/ehcache.xml index c30fb79..f2f6be5 100644 --- a/core/resources/ehcache.xml +++ b/core/resources/ehcache.xml @@ -24,8 +24,8 @@ diff --git a/core/resources/ehcache3.xml b/core/resources/ehcache3.xml index 3bfa495..16bf0a6 100644 --- a/core/resources/ehcache3.xml +++ b/core/resources/ehcache3.xml @@ -9,7 +9,7 @@ java.lang.String java.io.Serializable - 1800 + 3600 1000 diff --git a/core/resources/j2cache.properties b/core/resources/j2cache.properties index ce33bbc..ccdb2c9 100644 --- a/core/resources/j2cache.properties +++ b/core/resources/j2cache.properties @@ -31,15 +31,10 @@ jgroups.configXml = /network.xml j2cache.L1.provider_class = caffeine j2cache.L2.provider_class = redis -# When L2 provider isn't `redis`, using `L2.config_section = redis` to read redis configurations -# j2cache.L2.config_section = redis -# Enable/Disable ttl in redis cache data (if disabled, the object in redis will never expire) +# j2cache.L2.config_section = redis j2cache.sync_ttl_to_redis = true -# Whether to cache null objects by default -j2cache.default_cache_null_object = true - ######################################### # Cache Serialization Provider # values: diff --git a/core/src/net/oschina/j2cache/CacheChannel.java b/core/src/net/oschina/j2cache/CacheChannel.java index 2691adb..386691a 100644 --- a/core/src/net/oschina/j2cache/CacheChannel.java +++ b/core/src/net/oschina/j2cache/CacheChannel.java @@ -28,13 +28,12 @@ import java.util.stream.Collectors; */ public abstract class CacheChannel implements Closeable , AutoCloseable { + private static final boolean DEFAULT_CACHE_NULL_OBJECT = true; private static final Map _g_keyLocks = new ConcurrentHashMap<>(); private J2CacheConfig config; - private boolean defaultCacheNullObject ; public CacheChannel(J2CacheConfig config) { this.config = config; - this.defaultCacheNullObject = config.isDefaultCacheNullObject(); } /** @@ -60,37 +59,17 @@ public abstract class CacheChannel implements Closeable , AutoCloseable { * 读取缓存(用户无需判断返回的对象是否为空) * @param region Cache region name * @param key Cache data key - * @param cacheNullObject 是否缓存空对象 * @return cache object */ - public CacheObject get(String region, String key, boolean...cacheNullObject) { - + public CacheObject get(String region, String key) { CacheObject obj = new CacheObject(region, key, CacheObject.LEVEL_1); obj.setValue(CacheProviderHolder.getLevel1Cache(region).get(key)); - if(obj.rawValue() != null) - return obj; - - String lock_key = key + '%' + region; - synchronized (_g_keyLocks.computeIfAbsent(lock_key, v -> new Object())) { - obj.setValue(CacheProviderHolder.getLevel1Cache(region).get(key)); + if(obj.rawValue() == null) { + obj.setLevel(CacheObject.LEVEL_2); + obj.setValue(CacheProviderHolder.getLevel2Cache(region).get(key)); if(obj.rawValue() != null) - return obj; - - try { - obj.setLevel(CacheObject.LEVEL_2); - obj.setValue(CacheProviderHolder.getLevel2Cache(region).get(key)); - if (obj.rawValue() != null) - CacheProviderHolder.getLevel1Cache(region).put(key, obj.rawValue()); - else { - boolean cacheNull = (cacheNullObject.length>0)?cacheNullObject[0]: defaultCacheNullObject; - if(cacheNull) - set(region, key, new Object(), true); - } - } finally { - _g_keyLocks.remove(lock_key); - } + CacheProviderHolder.getLevel1Cache(region).put(key, obj.rawValue()); } - return obj; } @@ -99,7 +78,6 @@ public abstract class CacheChannel implements Closeable , AutoCloseable { * @param region Cache region name * @param key Cache data key * @param loader data loader - * @param cacheNullObject true if you need to cache null object * @return cache object */ public CacheObject get(String region, String key, Function loader, boolean...cacheNullObject) { @@ -117,9 +95,11 @@ public abstract class CacheChannel implements Closeable , AutoCloseable { try { Object obj = loader.apply(key); - boolean cacheNull = (cacheNullObject.length>0)?cacheNullObject[0]: defaultCacheNullObject; - set(region, key, obj, cacheNull); - cache = new CacheObject(region, key, CacheObject.LEVEL_OUTER, obj); + if (obj != null) { + boolean cacheNull = (cacheNullObject.length>0)?cacheNullObject[0]:DEFAULT_CACHE_NULL_OBJECT; + set(region, key, obj, cacheNull); + cache = new CacheObject(region, key, CacheObject.LEVEL_OUTER, obj); + } } finally { _g_keyLocks.remove(lock_key); } @@ -158,8 +138,7 @@ public abstract class CacheChannel implements Closeable , AutoCloseable { * @param region Cache region name * @param keys cache keys * @param loader data loader - * @param cacheNullObject true if you need to cache null object - * @return multiple cache data + * @return */ public Map get(String region, Collection keys, Function loader, boolean...cacheNullObject) { Map results = get(region, keys); @@ -170,10 +149,12 @@ public abstract class CacheChannel implements Closeable , AutoCloseable { if(cache == null) { try { Object obj = loader.apply(e.getKey()); - boolean cacheNull = (cacheNullObject.length>0)?cacheNullObject[0]: defaultCacheNullObject; - set(region, e.getKey(), obj, cacheNull); - e.getValue().setValue(obj); - e.getValue().setLevel(CacheObject.LEVEL_OUTER); + if (obj != null) { + boolean cacheNull = (cacheNullObject.length>0)?cacheNullObject[0]:DEFAULT_CACHE_NULL_OBJECT; + set(region, e.getKey(), obj, cacheNull); + e.getValue().setValue(obj); + e.getValue().setLevel(CacheObject.LEVEL_OUTER); + } } finally { _g_keyLocks.remove(lock_key); } @@ -198,8 +179,8 @@ public abstract class CacheChannel implements Closeable , AutoCloseable { /** * 判断某个key存在于哪级的缓存中 - * @param region cache region - * @param key cache key + * @param region + * @param key * @return 0(不存在),1(一级),2(二级) */ public int check(String region, String key) { @@ -218,7 +199,7 @@ public abstract class CacheChannel implements Closeable , AutoCloseable { * @param value: Cache value */ public void set(String region, String key, Object value) { - set(region, key, value, defaultCacheNullObject); + set(region, key, value, DEFAULT_CACHE_NULL_OBJECT); } /** @@ -230,9 +211,6 @@ public abstract class CacheChannel implements Closeable , AutoCloseable { * @param cacheNullObject if allow cache null object */ public void set(String region, String key, Object value, boolean cacheNullObject) { - if (!cacheNullObject && value == null) - return ; - try { Level1Cache level1 = CacheProviderHolder.getLevel1Cache(region); level1.put(key, (value==null && cacheNullObject)?new Object():value); @@ -258,7 +236,7 @@ public abstract class CacheChannel implements Closeable , AutoCloseable { * @param timeToLiveInSeconds cache expired in second */ public void set(String region, String key, Object value, long timeToLiveInSeconds ) { - set(region, key, value, timeToLiveInSeconds, defaultCacheNullObject); + set(region, key, value, timeToLiveInSeconds, DEFAULT_CACHE_NULL_OBJECT); } /** @@ -273,9 +251,6 @@ public abstract class CacheChannel implements Closeable , AutoCloseable { * @param cacheNullObject if allow cache null object */ public void set(String region, String key, Object value, long timeToLiveInSeconds, boolean cacheNullObject) { - if (!cacheNullObject && value == null) - return ; - if(timeToLiveInSeconds <= 0) set(region, key, value, cacheNullObject); else { @@ -298,7 +273,7 @@ public abstract class CacheChannel implements Closeable , AutoCloseable { * @param elements Cache Elements */ public void set(String region, Map elements){ - set(region, elements, defaultCacheNullObject); + set(region, elements, DEFAULT_CACHE_NULL_OBJECT); } /** @@ -348,7 +323,7 @@ public abstract class CacheChannel implements Closeable , AutoCloseable { * @param timeToLiveInSeconds cache expired in second */ public void set(String region, Map elements, long timeToLiveInSeconds){ - set(region, elements, timeToLiveInSeconds, defaultCacheNullObject); + set(region, elements, timeToLiveInSeconds, DEFAULT_CACHE_NULL_OBJECT); } /** @@ -424,7 +399,7 @@ public abstract class CacheChannel implements Closeable , AutoCloseable { /** * 返回所有的缓存区域 - * @return all the regions + * @return */ public Collection regions() { return CacheProviderHolder.regions(); diff --git a/core/src/net/oschina/j2cache/CacheObject.java b/core/src/net/oschina/j2cache/CacheObject.java index 3cd870e..18f718f 100644 --- a/core/src/net/oschina/j2cache/CacheObject.java +++ b/core/src/net/oschina/j2cache/CacheObject.java @@ -56,7 +56,7 @@ public class CacheObject { /** * 获取数据所在的缓存区域 - * @return cache region name + * @return */ public String getRegion() { return region; @@ -64,7 +64,7 @@ public class CacheObject { /** * 缓存数据键值 - * @return cache key + * @return */ public String getKey() { return key; @@ -72,7 +72,7 @@ public class CacheObject { /** * 缓存对象 - * @return cache object include null object + * @return */ public Object getValue() { if (value != null && value.getClass().equals(Object.class)) @@ -80,17 +80,13 @@ public class CacheObject { return value; } - /** - * 返回实际缓存的对象 - * @return cache raw object - */ Object rawValue() { return value; } /** * 缓存所在的层级 - * @return cache level + * @return */ public byte getLevel() { return level; @@ -118,7 +114,7 @@ public class CacheObject { @Override public String toString() { - return String.format("[%s,%s,L%d]=>%s", region, key, level, getValue()); + return String.format("[%s,%s,L%d]=>%s", region, key, level, value); } } diff --git a/core/src/net/oschina/j2cache/CacheProvider.java b/core/src/net/oschina/j2cache/CacheProvider.java index d3bf5bc..acc4a78 100644 --- a/core/src/net/oschina/j2cache/CacheProvider.java +++ b/core/src/net/oschina/j2cache/CacheProvider.java @@ -32,7 +32,7 @@ public interface CacheProvider { /** * 缓存的层级 - * @return current provider level + * @return */ int level(); @@ -60,7 +60,7 @@ public interface CacheProvider { /** * Return all channels defined in first level cache - * @return all regions name + * @return */ Collection regions(); diff --git a/core/src/net/oschina/j2cache/CacheProviderHolder.java b/core/src/net/oschina/j2cache/CacheProviderHolder.java index 4f173d9..dce3a4c 100644 --- a/core/src/net/oschina/j2cache/CacheProviderHolder.java +++ b/core/src/net/oschina/j2cache/CacheProviderHolder.java @@ -41,7 +41,6 @@ public class CacheProviderHolder { /** * Initialize Cache Provider - * @param config j2cache config instance * @param listener cache listener */ public static void init(J2CacheConfig config, CacheExpiredListener listener){ @@ -97,8 +96,8 @@ public class CacheProviderHolder { /** * 一级缓存实例 - * @param region cache region - * @return level 1 cache instance + * @param region + * @return */ public final static Level1Cache getLevel1Cache(String region) { return (Level1Cache)l1_provider.buildCache(region, listener); @@ -106,9 +105,9 @@ public class CacheProviderHolder { /** * 一级缓存实例 - * @param region cache region - * @param timeToLiveSeconds cache ttl - * @return level 1 cache instance + * @param region + * @param timeToLiveSeconds + * @return */ public final static Level1Cache getLevel1Cache(String region, long timeToLiveSeconds) { return (Level1Cache)l1_provider.buildCache(region, timeToLiveSeconds, listener); @@ -116,17 +115,13 @@ public class CacheProviderHolder { /** * 二级缓存实例 - * @param region cache region - * @return level 2 cache instance + * @param region + * @return */ public final static Level2Cache getLevel2Cache(String region) { return (Level2Cache)l2_provider.buildCache(region, listener); } - /** - * return all regions - * @return all regions - */ public final static Collection regions() { return l1_provider.regions(); } diff --git a/core/src/net/oschina/j2cache/ClusterPolicyFactory.java b/core/src/net/oschina/j2cache/ClusterPolicyFactory.java index b75d79a..301d9ce 100644 --- a/core/src/net/oschina/j2cache/ClusterPolicyFactory.java +++ b/core/src/net/oschina/j2cache/ClusterPolicyFactory.java @@ -29,9 +29,9 @@ public class ClusterPolicyFactory { /** * 初始化集群消息通知机制 - * @param broadcast j2cache.broadcast value - * @param props broadcast configuations - * @return ClusterPolicy instance + * @param broadcast + * @param props + * @return */ public final static ClusterPolicy init(String broadcast, Properties props) { ClusterPolicy policy; diff --git a/core/src/net/oschina/j2cache/J2CacheBuilder.java b/core/src/net/oschina/j2cache/J2CacheBuilder.java index 2c97101..c8e629b 100644 --- a/core/src/net/oschina/j2cache/J2CacheBuilder.java +++ b/core/src/net/oschina/j2cache/J2CacheBuilder.java @@ -56,8 +56,8 @@ public class J2CacheBuilder { /** * 初始化 J2Cache,这是一个很重的操作,请勿重复执行 - * @param config j2cache config instance - * @return J2CacheBuilder instance + * @param config + * @return */ public final static J2CacheBuilder init(J2CacheConfig config) { return new J2CacheBuilder(config); diff --git a/core/src/net/oschina/j2cache/J2CacheConfig.java b/core/src/net/oschina/j2cache/J2CacheConfig.java index 96722ce..045c4f9 100644 --- a/core/src/net/oschina/j2cache/J2CacheConfig.java +++ b/core/src/net/oschina/j2cache/J2CacheConfig.java @@ -37,7 +37,6 @@ public class J2CacheConfig { private String l2CacheName; private String serialization; private boolean syncTtlToRedis; - private boolean defaultCacheNullObject; private Properties broadcastProperties = new Properties(); private Properties l1CacheProperties = new Properties(); private Properties l2CacheProperties = new Properties(); @@ -52,7 +51,6 @@ public class J2CacheConfig { config.l1CacheName = config.properties.getProperty("j2cache.L1.provider_class"); config.l2CacheName = config.properties.getProperty("j2cache.L2.provider_class"); config.syncTtlToRedis = !"false".equalsIgnoreCase(config.properties.getProperty("j2cache.sync_ttl_to_redis")); - config.defaultCacheNullObject = "true".equalsIgnoreCase(config.properties.getProperty("j2cache.default_cache_null_object")); String l2_config_section = config.properties.getProperty("j2cache.L2.config_section"); if(l2_config_section == null || l2_config_section.trim().equals("")) @@ -118,14 +116,6 @@ public class J2CacheConfig { this.syncTtlToRedis = syncTtlToRedis; } - public boolean isDefaultCacheNullObject() { - return defaultCacheNullObject; - } - - public void setDefaultCacheNullObject(boolean defaultCacheNullObject) { - this.defaultCacheNullObject = defaultCacheNullObject; - } - public String getL1CacheName() { return l1CacheName; } diff --git a/core/src/net/oschina/j2cache/Level1Cache.java b/core/src/net/oschina/j2cache/Level1Cache.java index 3fe4026..7576f50 100644 --- a/core/src/net/oschina/j2cache/Level1Cache.java +++ b/core/src/net/oschina/j2cache/Level1Cache.java @@ -23,13 +23,13 @@ public interface Level1Cache extends Cache { /** * 返回该缓存区域的 TTL 设置(单位:秒) - * @return true if cache support ttl setting + * @return */ long ttl(); /** * 返回该缓存区域中,内存存储对象的最大数量 - * @return cache size in memory + * @return */ long size(); diff --git a/core/src/net/oschina/j2cache/Level2Cache.java b/core/src/net/oschina/j2cache/Level2Cache.java index 505c38a..9f6035a 100644 --- a/core/src/net/oschina/j2cache/Level2Cache.java +++ b/core/src/net/oschina/j2cache/Level2Cache.java @@ -32,7 +32,7 @@ public interface Level2Cache extends Cache { /** * 是否支持缓存 TTL 的设置 - * @return true/false if cache support ttl setting + * @return */ default boolean supportTTL() { return false; @@ -40,36 +40,36 @@ public interface Level2Cache extends Cache { /** * 读取缓存数据字节数组 - * @param key cache key - * @return cache data + * @param key + * @return */ byte[] getBytes(String key); /** * 同时读取多个 Key - * @param keys multiple cache key - * @return cache values + * @param keys + * @return */ List getBytes(Collection keys); /** * 设置缓存数据字节数组 - * @param key cache key - * @param bytes cache data + * @param key + * @param bytes */ void setBytes(String key, byte[] bytes); /** * 同时设置多个数据 - * @param bytes cache data + * @param bytes */ void setBytes(Map bytes); /** * 设置缓存数据字节数组(带有效期) - * @param key cache key - * @param bytes cache data - * @param timeToLiveInSeconds cache ttl + * @param key + * @param bytes + * @param timeToLiveInSeconds */ default void setBytes(String key, byte[] bytes, long timeToLiveInSeconds){ setBytes(key, bytes); @@ -77,8 +77,8 @@ public interface Level2Cache extends Cache { /** * 批量设置带 TTL 的缓存数据 - * @param bytes cache data - * @param timeToLiveInSeconds cache ttl + * @param bytes + * @param timeToLiveInSeconds */ default void setBytes(Map bytes, long timeToLiveInSeconds) { setBytes(bytes); @@ -87,7 +87,7 @@ public interface Level2Cache extends Cache { /** * 判断缓存数据是否存在 * @param key cache key - * @return true if cache key exists in redis + * @return */ default boolean exists(String key) { return getBytes(key) != null; @@ -149,9 +149,9 @@ public interface Level2Cache extends Cache { /** * 设置缓存数据的有效期 - * @param key cache key - * @param value cache value - * @param timeToLiveInSeconds cache ttl + * @param key + * @param value + * @param timeToLiveInSeconds */ default void put(String key, Object value, long timeToLiveInSeconds) { try { diff --git a/core/src/net/oschina/j2cache/MultiThreadTester.java b/core/src/net/oschina/j2cache/MultiThreadTester.java index 1dcf7d8..cb1b734 100644 --- a/core/src/net/oschina/j2cache/MultiThreadTester.java +++ b/core/src/net/oschina/j2cache/MultiThreadTester.java @@ -1,40 +1,32 @@ package net.oschina.j2cache; +import java.util.Random; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; /** * 对 J2Cache 进行多线程测试 */ public class MultiThreadTester { - public static void main(String[] args) throws InterruptedException { + public static void main(String[] args) { CacheChannel cache = J2Cache.getChannel(); - String region = "Users"; - String key = "ld"; - ExecutorService threadPool = Executors.newCachedThreadPool(); - cache.evict(region, key); - //cache.set(region, key, "Winter Lau"); - for(int i=0;i<100;i++) { final int seq = i; threadPool.execute(() -> { + Random seed = new Random(System.currentTimeMillis()); String name = "Thread-" + seq; - for(int j=0;j<1;j++) { + for(int j=0;j<100;j++) { long ct = System.currentTimeMillis(); - System.out.printf("%s -> %s (%dms)\n", name, cache.get(region, key), (System.currentTimeMillis()-ct)); + String rand = String.valueOf(seed.nextInt()); + cache.set("Users", rand, seed.nextDouble()); + System.out.printf("%s -> %s (%dms)\n", name, cache.get("Users", rand).getValue(), (System.currentTimeMillis()-ct)); } }); } - - threadPool.shutdown(); - threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); - - System.exit(0); } } diff --git a/core/src/net/oschina/j2cache/redis/RedisCacheProvider.java b/core/src/net/oschina/j2cache/redis/RedisCacheProvider.java index 90cca34..abc0adc 100644 --- a/core/src/net/oschina/j2cache/redis/RedisCacheProvider.java +++ b/core/src/net/oschina/j2cache/redis/RedisCacheProvider.java @@ -130,7 +130,7 @@ public class RedisCacheProvider implements CacheProvider { /** * 获取 Redis 客户端实例 - * @return redis client interface instance + * @return */ public RedisClient getRedisClient() { return redisClient; diff --git a/core/src/net/oschina/j2cache/redis/RedisUtils.java b/core/src/net/oschina/j2cache/redis/RedisUtils.java index 132d236..77e073e 100644 --- a/core/src/net/oschina/j2cache/redis/RedisUtils.java +++ b/core/src/net/oschina/j2cache/redis/RedisUtils.java @@ -8,9 +8,8 @@ public class RedisUtils { /** * 初始化 Redis 连接池 - * @param props j2cache.properties - * @param prefix configuration prefix - * @return redis connection pool configuration object + * @param props + * @return */ public final static JedisPoolConfig newPoolConfig(Properties props, String prefix) { JedisPoolConfig cfg = new JedisPoolConfig(); diff --git a/core/src/net/oschina/j2cache/util/FSTSerializer.java b/core/src/net/oschina/j2cache/util/FSTSerializer.java index 152bf3e..4e14b8c 100644 --- a/core/src/net/oschina/j2cache/util/FSTSerializer.java +++ b/core/src/net/oschina/j2cache/util/FSTSerializer.java @@ -20,7 +20,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import net.oschina.j2cache.CacheException; -import org.nustaq.serialization.FSTConfiguration; import org.nustaq.serialization.FSTObjectInput; import org.nustaq.serialization.FSTObjectOutput; @@ -31,13 +30,6 @@ import org.nustaq.serialization.FSTObjectOutput; */ public class FSTSerializer implements Serializer { - private FSTConfiguration fstConfiguration ; - - public FSTSerializer() { - fstConfiguration = FSTConfiguration.getDefaultConfiguration(); - fstConfiguration.setClassLoader(Thread.currentThread().getContextClassLoader()); - } - @Override public String name() { return "fst"; @@ -46,7 +38,7 @@ public class FSTSerializer implements Serializer { @Override public byte[] serialize(Object obj) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); - try (FSTObjectOutput fOut = new FSTObjectOutput(out, fstConfiguration)) { + try (FSTObjectOutput fOut = new FSTObjectOutput(out)) { fOut.writeObject(obj); fOut.flush(); return out.toByteArray(); @@ -57,7 +49,7 @@ public class FSTSerializer implements Serializer { public Object deserialize(byte[] bytes) throws IOException { if(bytes == null || bytes.length == 0) return null; - try (FSTObjectInput in = new FSTObjectInput(new ByteArrayInputStream(bytes), fstConfiguration)){ + try (FSTObjectInput in = new FSTObjectInput(new ByteArrayInputStream(bytes))){ return in.readObject(); } catch (ClassNotFoundException e) { throw new CacheException(e); diff --git a/core/src/net/oschina/j2cache/util/SerializationUtils.java b/core/src/net/oschina/j2cache/util/SerializationUtils.java index 8252903..20fddc3 100644 --- a/core/src/net/oschina/j2cache/util/SerializationUtils.java +++ b/core/src/net/oschina/j2cache/util/SerializationUtils.java @@ -33,7 +33,7 @@ public class SerializationUtils { /** * 初始化序列化器 - * @param ser serialization method + * @param ser */ public static void init(String ser) { if (ser == null || "".equals(ser.trim())) diff --git a/modules/hibernate3/pom.xml b/modules/hibernate3/pom.xml index 2c61d2d..0ffdf83 100755 --- a/modules/hibernate3/pom.xml +++ b/modules/hibernate3/pom.xml @@ -3,8 +3,7 @@ net.oschina.j2cache j2cache - 2.3.17-release - ../../pom.xml + 2.3.16-release 4.0.0 @@ -20,7 +19,6 @@ net.oschina.j2cache j2cache-core ${j2cache-version} - compile org.hibernate diff --git a/modules/hibernate4/pom.xml b/modules/hibernate4/pom.xml index bd1ce72..2ccb63e 100755 --- a/modules/hibernate4/pom.xml +++ b/modules/hibernate4/pom.xml @@ -3,8 +3,7 @@ net.oschina.j2cache j2cache - 2.3.17-release - ../../pom.xml + 2.3.16-release 4.0.0 @@ -22,7 +21,6 @@ net.oschina.j2cache j2cache-core ${j2cache-version} - compile org.hibernate diff --git a/modules/mybatis/pom.xml b/modules/mybatis/pom.xml index b210480..e824155 100644 --- a/modules/mybatis/pom.xml +++ b/modules/mybatis/pom.xml @@ -5,25 +5,23 @@ j2cache net.oschina.j2cache - 2.3.17-release - ../../pom.xml + 2.3.16-release 4.0.0 j2cache-mybatis + 2.3.17-release net.oschina.j2cache j2cache-core ${j2cache-version} - compile org.mybatis mybatis 3.4.6 - compile mysql diff --git a/modules/spring-boot-starter/pom.xml b/modules/spring-boot-starter/pom.xml index 088cb32..ba9e15f 100644 --- a/modules/spring-boot-starter/pom.xml +++ b/modules/spring-boot-starter/pom.xml @@ -5,8 +5,7 @@ j2cache net.oschina.j2cache - 2.3.17-release - ../../pom.xml + 2.3.16-release 4.0.0 @@ -17,7 +16,6 @@ net.oschina.j2cache j2cache-core ${j2cache-version} - compile org.springframework.boot diff --git a/modules/spring-boot2-starter/pom.xml b/modules/spring-boot2-starter/pom.xml index 17cc9b6..14d879c 100644 --- a/modules/spring-boot2-starter/pom.xml +++ b/modules/spring-boot2-starter/pom.xml @@ -5,8 +5,7 @@ j2cache net.oschina.j2cache - 2.3.17-release - ../../pom.xml + 2.3.16-release 4.0.0 @@ -17,7 +16,6 @@ net.oschina.j2cache j2cache-core ${j2cache-version} - compile org.springframework.boot diff --git a/pom.xml b/pom.xml index 32340bd..a17a472 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ net.oschina.j2cache j2cache - 2.3.19-release + 2.3.16-release pom j2cache @@ -39,7 +39,7 @@ UTF-8 - 2.3.19-release + 2.3.16-release -- Gitee