diff --git a/CHANGES.md b/CHANGES.md index b30fd5b43eb0af57f8d5fddedb73ad7cd204a5e0..364815a80cef55790d21bc4cb1d94285872174ff 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 0c91349b7dcdaacdc65f2aa0f7a3607ca7726fa6..617fda71634885ff2e067f70171371cc03ad39b1 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 ab14474ca864b033c4ef05277c28f0e80d3af15c..ef35139de22a6cb68184378c89dc8210eb86562d 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 c30fb79b336a0c5f5a81ce9f5ba3b83022a5b445..f2f6be5528e301c36ffec518d2be1b54b34172de 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 3bfa495b15c54eb82134ea8dfb24fd738e5d1066..16bf0a6f693132118fcbe4ac9b0fd2dfe8a0ce7b 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 ce33bbc22c0c6aadf93d954cb0740009215ac3d6..ccdb2c9212092c5fce4553a2832b8c4fc2acd8c2 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 2691adbf8580d9158601a65ea5133e42c3d72846..386691a93881ab5841322ff1f0f15c989a640e2d 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 3cd870e7a8ce9ea9857206f7195da04a3ee705d0..18f718f6c119b7309b92d09308d96cc8858dccaf 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 d3bf5bcf3bee6a8b09cb42b8a7ca5be8fea9563e..acc4a78156be7069f97fa778e618d87cfe772f1d 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 4f173d97febfb1aa6c232c756f526601ba96ea3e..dce3a4c1ae391843902b40b5a940fea2be2dc121 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 b75d79ab30305d9d6df870c27971a5644f943830..301d9ce1a298a260c30cb4feca42ccb0e7527f54 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 2c971015f9bbd0970267845fd903310d520403b6..c8e629b3506e0a0f2feca0c2b9ea637b082d02fd 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 96722ce256c1f871dc02c2cb2243809566a5c3d3..045c4f986c92157e876517ebcb305473556cd0bd 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 3fe4026f16070760aaeca2ca8793da412ac2e878..7576f5002832da7bcdf0649734ef7e41d6d5f3da 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 505c38a7cc378d1fe4039c64df60cc071ca3650f..9f6035a5b4b4b321aa59c822c903f70aa83afaa5 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 1dcf7d8fff4469ac05009c72bc2564ffbe26ae56..cb1b734b866cea262db3401003d137fd3f928fe9 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 90cca34cf86b0ec972d9e2d1484ebfd0a25bce15..abc0adc860378ae9e77963bd27e62049e6168a80 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 132d236b014efcd2acbcb09e2f7bc03492992775..77e073eb3e2e4f5eac58f133a7db52eeae79d802 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 152bf3e1e9e16967f0667665a705fb1e97245115..4e14b8c79f9f87d9e67cc4da104ebb7078e5b532 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 8252903be1d648022cb6d846a2555ba671331860..20fddc35aad35276e54edbb5a9fda9c07fdd2c5b 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 2c61d2decc6a930da8d0937e69e85d7e750baa61..0ffdf837670c7024a8d3b0a5646e6f67b7062035 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 bd1ce72a3d93e382336e105cafdb41896be061ee..2ccb63e6c104893d463e2dd9121c37958310cb86 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 b210480844b4c4c49931c81d0cc1800fb89aab7e..e824155e31bedc15c552fb6d908622fce6df50ed 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 088cb32f4e953a11348edcf250a7be629dd4b486..ba9e15fd1d1d6ae8ba89967c7d1efc60e0d73ecc 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 17cc9b66ce9e2304004f6775605a533e9adf52ac..14d879c49177120a689a1e8f1819135a8fb7cda8 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 32340bd05bc6c21b220191577b02dc465523d7cd..a17a4725b3afa902964c48da7eb73e0193133ec0 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