本文实例讲述了java使用hashmap缓存保存数据的方法。分享给大家供大家参考,具体如下:
private static final HashMap<Long, XXX> sCache = new HashMap<Long, XXX>();
private static int sId = -1;
public static void initAlbumArtCache() {
try {
//。。。
if (id != sId) {
clearCache();
sId = id;
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
public static void clearCache() {
synchronized(sCache) {
sCache.clear();
}
}
public static XXX getCachedXXX(long Index, BitmapDrawable defaultBitmap) {
XXX d = null;
synchronized(sCache) {
d = sCache.get(Index);
}
if (d == null) {
//。。。
synchronized(sArtCache) {
// the cache may have changed since we checked
XXX value = sCache.get(Index);
if (value == null) {
sCache.put(Index, d);
} else {
d = value;
}
}
}
return d;
}希望本文所述对大家java程序设计有所帮助。
更多java使用hashMap缓存保存数据的方法相关文章请关注PHP中文网!
SHOPEX简灰服装商城整站源码下载。 安装方法:1.解压上传程序至网站根目录.. 访问:域名/bak.(用户名:admin 密码:123456)2.进入帝国备份王后,配置数据库数据库信息.选择-www.taomoban.net目录.还原数据库.3.修改FTP目录下的config/config.phpphp 数据库连接信息.4.登陆网站后台--清空缓存..5.删除bak文件夹 后台:shopadm










