We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
经过简单阅读源码,发现不能刷新页面的根本原因是DPCMannager中用了大量静态集合来保存缓存日期对象(DATE_CACHE),我遇到的场景就是今日日期未更新,简单来说,只要清空缓存就可以,由于我是使用jar包的形式来导入的,所以我用反射来清缓存(如果用maven的,也应该用反射): try { DPCManager instance = DPCManager.getInstance(); Field DATE_CACHEFeild = DPCManager.class.getDeclaredField("DATE_CACHE"); DATE_CACHEFeild.setAccessible(true); HashMap DATE_CACHE = (HashMap) DATE_CACHEFeild.get(instance); DATE_CACHE.clear(); } catch (Exception e) { e.printStackTrace(); } 假如是用依赖工程:直接在DPCMannager暴露一个方法清理缓存,就好了。 最后留言一句:过分利用单例,很容易出问题,最起码暴露一个清除方法方便复用。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
经过简单阅读源码,发现不能刷新页面的根本原因是DPCMannager中用了大量静态集合来保存缓存日期对象(DATE_CACHE),我遇到的场景就是今日日期未更新,简单来说,只要清空缓存就可以,由于我是使用jar包的形式来导入的,所以我用反射来清缓存(如果用maven的,也应该用反射):
try {
DPCManager instance = DPCManager.getInstance();
Field DATE_CACHEFeild = DPCManager.class.getDeclaredField("DATE_CACHE");
DATE_CACHEFeild.setAccessible(true);
HashMap DATE_CACHE = (HashMap) DATE_CACHEFeild.get(instance);
DATE_CACHE.clear();
} catch (Exception e) {
e.printStackTrace();
}
假如是用依赖工程:直接在DPCMannager暴露一个方法清理缓存,就好了。
最后留言一句:过分利用单例,很容易出问题,最起码暴露一个清除方法方便复用。
The text was updated successfully, but these errors were encountered: