diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/FileCacheStorager.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/FileCacheStorager.java index 998c5096..ff611e59 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/FileCacheStorager.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/FileCacheStorager.java @@ -21,16 +21,16 @@ public class FileCacheStorager implements CacheStorager private final File tmpdir; private final String SEPARATOR = File.separator; - public FileCacheStorager(String cachePath) { + public FileCacheStorager(String path) { this.tmpdir = new File(String.format("%s%sweixin4j_token_temp", - cachePath, SEPARATOR)); + path, SEPARATOR)); this.tmpdir.mkdirs(); } @Override - public T lookup(String cacheKey) { + public T lookup(String key) { File cacheFile = new File(String.format("%s%s%s", - tmpdir.getAbsolutePath(), SEPARATOR, cacheKey)); + tmpdir.getAbsolutePath(), SEPARATOR, key)); try { if (cacheFile.exists()) { T cache = SerializationUtils.deserialize(new FileInputStream( @@ -50,22 +50,22 @@ public class FileCacheStorager implements CacheStorager } @Override - public void caching(String cacheKey, T cache) { + public void caching(String key, T cache) { try { SerializationUtils.serialize( cache, new FileOutputStream(new File(String.format("%s%s%s", - tmpdir.getAbsolutePath(), SEPARATOR, cacheKey)))); + tmpdir.getAbsolutePath(), SEPARATOR, key)))); } catch (IOException e) { throw new RuntimeException(e); } } @Override - public T evict(String cacheKey) { + public T evict(String key) { T cache = null; File cacheFile = new File(String.format("%s%s%s", - tmpdir.getAbsolutePath(), SEPARATOR, cacheKey)); + tmpdir.getAbsolutePath(), SEPARATOR, key)); try { if (cacheFile.exists()) { cache = SerializationUtils.deserialize(new FileInputStream( diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/MemcacheCacheStorager.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/MemcacheCacheStorager.java index 42895c19..1d2a8dd6 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/MemcacheCacheStorager.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/MemcacheCacheStorager.java @@ -35,32 +35,32 @@ public class MemcacheCacheStorager implements @SuppressWarnings("unchecked") @Override - public T lookup(String cacheKey) { - return (T) mc.get(cacheKey); + public T lookup(String key) { + return (T) mc.get(key); } @SuppressWarnings("unchecked") @Override - public void caching(String cacheKey, T cache) { + public void caching(String key, T cache) { if (cache.getCreateTime() > 0l) { - mc.set(cacheKey, + mc.set(key, cache, new Date(cache.getCreateTime() + cache.getExpires() - CUTMS)); } else { - mc.set(cacheKey, cache); + mc.set(key, cache); } Set all = (Set) mc.get(ALLKEY); - all.add(cacheKey); + all.add(key); mc.set(ALLKEY, all); } @SuppressWarnings("unchecked") @Override - public T evict(String cacheKey) { - T cache = lookup(cacheKey); - mc.delete(cacheKey); + public T evict(String key) { + T cache = lookup(key); + mc.delete(key); Set all = (Set) mc.get(ALLKEY); - all.remove(cacheKey); + all.remove(key); mc.set(ALLKEY, all); return cache; } diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/MemoryCacheStorager.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/MemoryCacheStorager.java index e0562013..481ac571 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/MemoryCacheStorager.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/MemoryCacheStorager.java @@ -22,8 +22,8 @@ public class MemoryCacheStorager implements } @Override - public T lookup(String cacheKey) { - T cache = this.CONMAP.get(cacheKey); + public T lookup(String key) { + T cache = this.CONMAP.get(key); if (cache != null) { if ((cache.getCreateTime() + cache.getExpires() - CUTMS) > System .currentTimeMillis()) { @@ -34,13 +34,13 @@ public class MemoryCacheStorager implements } @Override - public void caching(String cacheKey, T cache) { - this.CONMAP.put(cacheKey, cache); + public void caching(String key, T cache) { + this.CONMAP.put(key, cache); } @Override - public T evict(String cacheKey) { - return this.CONMAP.remove(cacheKey); + public T evict(String key) { + return this.CONMAP.remove(key); } @Override diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/RedisCacheStorager.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/RedisCacheStorager.java index ab40fcb3..f7232c52 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/RedisCacheStorager.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/RedisCacheStorager.java @@ -60,11 +60,11 @@ public class RedisCacheStorager implements @SuppressWarnings("unchecked") @Override - public T lookup(String cacheKey) { + public T lookup(String key) { Jedis jedis = null; try { jedis = jedisPool.getResource(); - byte[] value = jedis.get(cacheKey.getBytes(Consts.UTF_8)); + byte[] value = jedis.get(key.getBytes(Consts.UTF_8)); return value != null ? (T) SerializationUtils.deserialize(value) : null; } finally { @@ -75,19 +75,19 @@ public class RedisCacheStorager implements } @Override - public void caching(String cacheKey, T cache) { + public void caching(String key, T cache) { Jedis jedis = null; try { jedis = jedisPool.getResource(); - byte[] key = cacheKey.getBytes(Consts.UTF_8); + byte[] cacheKey = key.getBytes(Consts.UTF_8); byte[] value = SerializationUtils.serialize(cache); if (cache.getExpires() > 0) { - jedis.setex(key, (int) (cache.getExpires() - CUTMS) / 1000, + jedis.setex(cacheKey, (int) (cache.getExpires() - CUTMS) / 1000, value); } else { - jedis.set(key, value); + jedis.set(cacheKey, value); } - jedis.sadd(ALLKEY, cacheKey); + jedis.sadd(ALLKEY, key); } finally { if (jedis != null) { jedis.close(); @@ -96,13 +96,13 @@ public class RedisCacheStorager implements } @Override - public T evict(String cacheKey) { - T cache = lookup(cacheKey); + public T evict(String key) { + T cache = lookup(key); Jedis jedis = null; try { jedis = jedisPool.getResource(); - jedis.del(cacheKey); - jedis.srem(ALLKEY, cacheKey); + jedis.del(key); + jedis.srem(ALLKEY, key); } finally { if (jedis != null) { jedis.close(); diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/RedisClusterCacheStorager.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/RedisClusterCacheStorager.java index b2ea171f..162e5f39 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/RedisClusterCacheStorager.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/RedisClusterCacheStorager.java @@ -59,29 +59,29 @@ public class RedisClusterCacheStorager implements @SuppressWarnings("unchecked") @Override - public T lookup(String cacheKey) { - byte[] value = jedisCluster.get(cacheKey.getBytes(Consts.UTF_8)); + public T lookup(String key) { + byte[] value = jedisCluster.get(key.getBytes(Consts.UTF_8)); return value != null ? (T) SerializationUtils.deserialize(value) : null; } @Override - public void caching(String cacheKey, T cache) { - byte[] key = cacheKey.getBytes(Consts.UTF_8); + public void caching(String key, T cache) { + byte[] cacheKey = key.getBytes(Consts.UTF_8); byte[] value = SerializationUtils.serialize(cache); if (cache.getExpires() > 0) { - jedisCluster.setex(key, (int) (cache.getExpires() - CUTMS) / 1000, - value); + jedisCluster.setex(cacheKey, + (int) (cache.getExpires() - CUTMS) / 1000, value); } else { - jedisCluster.set(key, value); + jedisCluster.set(cacheKey, value); } - jedisCluster.sadd(ALLKEY, cacheKey); + jedisCluster.sadd(ALLKEY, key); } @Override - public T evict(String cacheKey) { - T cache = lookup(cacheKey); - jedisCluster.del(cacheKey); - jedisCluster.srem(ALLKEY, cacheKey); + public T evict(String key) { + T cache = lookup(key); + jedisCluster.del(key); + jedisCluster.srem(ALLKEY, key); return cache; } diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/token/PerTicketManager.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/token/PerTicketManager.java index dd2cc3cb..6c192e94 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/token/PerTicketManager.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/token/PerTicketManager.java @@ -4,7 +4,7 @@ import com.foxinmy.weixin4j.cache.CacheStorager; import com.foxinmy.weixin4j.model.Token; /** - * 第三方应用组件永久授权码的存取 + * 第三方应用永久授权码的存取 * * @className PerTicketManager * @author jinyu(foxinmy@gmail.com) diff --git a/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/WeixinComponentProxy.java b/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/WeixinComponentProxy.java index 1a750784..02c7b5aa 100644 --- a/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/WeixinComponentProxy.java +++ b/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/WeixinComponentProxy.java @@ -125,7 +125,7 @@ public class WeixinComponentProxy { * 组件ticket内容 * @throws WeixinException */ - public void cacheTicket(String componentId, String componentTicket) throws WeixinException { + public void cacheComponentTicket(String componentId, String componentTicket) throws WeixinException { component(componentId).getTicketManager().cachingTicket(componentTicket); } @@ -135,7 +135,7 @@ public class WeixinComponentProxy { * @see {@link #getComponentAuthorizeURL(String, String,String)} * @param componentId * 组件ID - * @see {@link #cacheTicket(String, String)} + * @see {@link #cacheComponentTicket(String, String)} * @return 请求授权的URL * @throws WeixinException */ diff --git a/weixin4j-qy/src/main/java/com/foxinmy/weixin4j/qy/WeixinSuiteProxy.java b/weixin4j-qy/src/main/java/com/foxinmy/weixin4j/qy/WeixinSuiteProxy.java index 07b57a02..b85170e5 100644 --- a/weixin4j-qy/src/main/java/com/foxinmy/weixin4j/qy/WeixinSuiteProxy.java +++ b/weixin4j-qy/src/main/java/com/foxinmy/weixin4j/qy/WeixinSuiteProxy.java @@ -146,7 +146,7 @@ public class WeixinSuiteProxy { * 推送suite_ticket协议 * @throws WeixinException */ - public void cacheTicket(String suiteId, String suiteTicket) throws WeixinException { + public void cacheSuiteTicket(String suiteId, String suiteTicket) throws WeixinException { suite(suiteId).getTicketManager().cachingTicket(suiteTicket); } @@ -156,7 +156,7 @@ public class WeixinSuiteProxy { * @see {@link #getSuiteAuthorizeURL(String, String,String)} * @param suiteId * 套件ID - * @see {@link #cacheTicket(String, String)} + * @see {@link #cacheSuiteTicket(String, String)} * @return 请求授权的URL * @throws WeixinException */