ASimpleCache是什么
ASimpleCache 是一个为android制定的 轻量级的 开源缓存框架。轻量到只有一个java文件(由十几个类精简而来)。
ASimpleCache可以缓存什么东西
普通的字符串、JsonObject、JsonArray、Bitmap、Drawable、序列化的java对象,和 byte数据。
ASimpleCache使用场景
替换SharePreference当做配置文件可以缓存网络请求数据,比如oschina的android客户端可以缓存http请求的新闻内容,缓存时间假设为1个小时,超时后自动失效,让客户端重新请求新的数据,减少客户端流量,同时减少服务器并发量。
使用教程
ACache mCache = ACache.get(
this);
mCache.put(
"test_key1",
"test value");
mCache.put(
"test_key2",
"test value",
10);
mCache.put(
"test_key3",
"test value",
2 * ACache.TIME_DAY);
ACache mCache = ACache.get(
this);
String value = mCache.getAsString(
"test_key1");
Github地址:https://github.com/yangfuhai/ASimpleCache