Merge branch 'master' of https://github.com/foxinmy/weixin4j.git
Conflicts: weixin4j-base/src/main/java/com/foxinmy/weixin4j/token/TokenHolder.java
This commit is contained in:
commit
333ca283b3
@ -41,10 +41,10 @@ public interface CacheStorager<T> {
|
||||
* 缓存key
|
||||
* @return 移除的对象
|
||||
*/
|
||||
T evict(String cacheKey);
|
||||
T evict(String cacheKey) throws WeixinException;
|
||||
|
||||
/**
|
||||
* 清除所有缓存对象(<font color="red">请慎重</font>)
|
||||
*/
|
||||
void clear();
|
||||
void clear() throws WeixinException;
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ public class FileTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token evict(String cacheKey) {
|
||||
public Token evict(String cacheKey) throws WeixinException {
|
||||
Token token = null;
|
||||
File token_file = new File(String.format("%s/%s.xml", cachePath,
|
||||
cacheKey));
|
||||
@ -79,7 +79,7 @@ public class FileTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
public void clear() throws WeixinException {
|
||||
File[] files = new File(cachePath).listFiles(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
|
||||
@ -41,12 +41,12 @@ public class MemoryTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token evict(String cacheKey) {
|
||||
public Token evict(String cacheKey) throws WeixinException {
|
||||
return this.CONMAP.remove(cacheKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
public void clear() throws WeixinException {
|
||||
this.CONMAP.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ public class RedisTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token evict(String cacheKey) {
|
||||
public Token evict(String cacheKey) throws WeixinException {
|
||||
Token token = null;
|
||||
try {
|
||||
token = lookup(cacheKey);
|
||||
@ -123,7 +123,7 @@ public class RedisTokenStorager implements TokenStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
public void clear() throws WeixinException {
|
||||
// en....
|
||||
}
|
||||
}
|
||||
@ -74,4 +74,15 @@ public class TokenHolder {
|
||||
tokenStorager.caching(cacheKey, token);
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动移除token
|
||||
*
|
||||
* @return 被移除的token
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public Token evictToken() throws WeixinException {
|
||||
String cacheKey = tokenCreator.getCacheKey();
|
||||
return tokenStorager.evict(cacheKey);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user