android基础---->LruCache的使用及原理
在你应用程序的UI界面加载一张图片是一件很简单的事情,但是当你需要在界面上加载一大堆图片的时候,情况就变得复杂起来。Android为我们提供了LruCache,今天我们就来学习这个缓存的知识以及原理。
目录导航
LruCache缓存的实例代码
一、 我们建立一个简单的项目去体会LruCache的使用过程
通过http请求网络上的图片文件,然后保存在缓存中。显示图片时,先从缓存中取,如果没有,就发送请求向服务器取。项目结构如下:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAARYAAAC3CAIAAABYGObnAAARRUlEQVR4nO2dzW/b5h3H9VfstksPO+2yw4YS2Ioga7FgRXvqpetlKAYe2lNQ2GiarVmBoekrUaxA0rehQYe1KxxJzuwwjucmjW00CZLFcZI6sZwXYLGiAk1jR7acak3AHSiRz8uP5EM+lESK3w8IWKKeh6Sk52M+pPh8WXL0+GLfs4oTV61mGaVSqWTamqtXwV2XYdViFFcuzdeKv3Eg95Qcx5mcnCxTTExMRNYfPoVsM05pvlb8jQO5p+Q4Tr1eJxWq1+uR9Qk9VMqwCrmPTds2S6WSebj7lCnnmWabpS6m7S2lVBIaPV/MU6g7mynql3RnMjW91Ypl5DV4zyI/LjB8dL716elpwZ/p6WmV+qkpZBjunGCFuOZdMm1xTlAxbvnBJXkZAlYhmQuFCk/nW282m5VKxfOnUqk0m02V+ioKrV46vnrpODdLVsj7Fx+kkNtOA7p+fu9LLsYt331ZKskcAHEdObIM1dVDR66w+P845+fnPYXm5uYU64cotPOzk8Lkv0Z15LiXJIWEUuxSuhhWjSrGHwt57V+o7G0OK0hAGWbXxC9W8UMDw4SvULvdrlar7i6o3W4r1u+VQp2m6e8F5BMQ7KkzUQx5LxSgkHzeQFaIPrfgecSIp/ihgWGC674vLCyUy+XFxUX1+ukrJB1+BB3kSLsI4owAdzrBXzpVUj57EHS4FTxP/XMDQ4P4rc/MzMSqH3QKe/XS8aQK+W20q0n3NVYatn0blsUengjFAhUSOmrSWphDoECFvD1UzTKgUCHR/dYTKgTAsNDDf5xQCBQ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ACQgWwrBIpA7UlDoyJEj6+vrCSqSCpGT/kYC0CNSUKhcLpfL5dnZ2Xa7HasiFAJDQGoKlcvlSqVy8eJF9Yoqelw7Xb12uqq3gQD0kDQVcpmYmKjX6yoVgxT63/KT35382YPbIzcnH/p27qc3Pvvx2qmfM6+7lxCzaWzs7XCD74QLQA9IXyGXy5cvR1YMUqhl/3Ll3Z88uD1y6c2Hlt566PjOH3138BfM664dxPg1KlIDgN6SvkLj4+NXr15VqRik0Pzcl2/sfYWd5ue+ZF7n/ZCiBLzh0RhyCfpAygqdOXPmwQPVOyPodeS6z8KGVgZF8gKQGqkpdOzYsVYrXpS7TkeO6aVxaQK22YkfsGyyMAApk4JCExMTjQYRuRYJef762unq2Id/idGRc+hTB37/DgKBXpK5qxOuna5GdeQAyBBZvMw0qiMHQIbIokIA5AgoBIAWUAgALaAQAFpAIQC0gEIAaAGFANACCgGgRbauTkBwAsgd2VIIFoHcgfgRALRA/AhGQwAtED8ChYAWeYwfoQcIyfPChxEx48P95wgtAXHJZ/yI2R3K7Y1YlfclxN6FCioJurM8AGrkMX7EcYjdhZw3Is2hg0pYbxBaAmKTw/iRmmV4zVzcb8h5I8wcOqiE3n9BJKBIDuNHGBNqluF15MS8ESKBhAoq4TtyCC0Bcclr/EinJ2aaXlOX80aIBJKQ8xDC6QUIBNTI3NUJiB8B+SKLl5kifgTkiCwqBECOgEIAaAGFANACCgGgxf8BBvoYYHviOpIAAAAASUVORK5CYII=" alt="" />
二、 在AndroidManifest.xml文件中,加入网络权限的声明:
<uses-permission android:name="android.permission.INTERNET"/>
三、 创建一个图片加载的类,用于对缓存的一些操作,重写LruCache的sizeOf方法:
package com.example.linux.lrucachetest; import android.graphics.Bitmap;
import android.util.LruCache; /**
* Created by huhx on 2016/4/12.
*/
public class ImageDownloader {
private static final String TAG = "TextDownload";
private LruCache<String, Bitmap> lruCache; public ImageDownloader() {
long maxMemory = Runtime.getRuntime().maxMemory();
int cacheSize = (int) (maxMemory / 8);
lruCache = new LruCache<String, Bitmap>(cacheSize) {
@Override
protected int sizeOf(String key, Bitmap value) {
return value.getByteCount();
}
};
} // 把Bitmap对象加入到缓存中
public void addBitmapToMemory(String key, Bitmap bitmap) {
if (getBitmapFromMemCache(key) == null) {
lruCache.put(key, bitmap);
}
} // 从缓存中得到Bitmap对象
public Bitmap getBitmapFromMemCache(String key) {
Log.i(TAG, "lrucache size: " + lruCache.size());
return lruCache.get(key);
} // 从缓存中删除指定的Bitmap
public void removeBitmapFromMemory(String key) {
lruCache.remove(key);
}
}
四、 在MainActivity中使用并测试LruCache:showBitmap方法是先从缓存中取,如果没有就发送http请求取得。
public void showBitmap(View view) {
Bitmap bitmap = imageDownloader.getBitmapFromMemCache("bitmap");
if (bitmap == null) {
new BitmapThread(bitmapUrl).start();
} else {
imageView.setImageBitmap(bitmap);
}
}
五、 BitmapThread的线程:从服务器拿到Bitmap对象,并加入到缓存中。
class BitmapThread extends Thread {
private String bitmapUrl; BitmapThread(String bitmapUrl) {
this.bitmapUrl = bitmapUrl;
} @Override
public void run() {
Log.i(TAG, "run: " + Thread.currentThread().getName());
Bitmap bitmap = null;
HttpURLConnection connection = null;
InputStream inputStream = null;
try {
URL url = new URL(bitmapUrl);
connection = (HttpURLConnection) url.openConnection();
connection.setConnectTimeout(5000);
connection.setRequestMethod("GET"); if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
inputStream = connection.getInputStream();
bitmap = BitmapFactory.decodeStream(inputStream);
}
imageDownloader.addBitmapToMemory("bitmap", bitmap);
handler.obtainMessage(DOWNLOAD_IMAGE, bitmap).sendToTarget();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (connection != null) {
connection.disconnect();
}
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
六、 handler处理消息,并显示图片:
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
Log.i(TAG, "hanlder handleMessage: " + Thread.currentThread().getName());
switch (msg.what) {
case DOWNLOAD_IMAGE:
imageView.setImageBitmap((Bitmap) msg.obj);
break;
}
}
};
七、 从缓存中删除图片:
public void remove(View view) {
imageDownloader.removeBitmapFromMemory("bitmap");
}
八、 输出日志结果如下:
第一次点击showBitmap:
- ::21.768 -/com.example.linux.lrucachetest I/TextDownload: lrucache size:
- ::21.771 -/com.example.linux.lrucachetest I/MainActivity: run: Thread-
- ::21.816 -/com.example.linux.lrucachetest I/TextDownload: lrucache size:
- ::21.817 -/com.example.linux.lrucachetest I/MainActivity: hanlder handleMessage: main
第二次点击showBitmap:
- ::11.128 -/com.example.linux.lrucachetest I/TextDownload: lrucache size:
点击remove之后,再点击showBitmap:
- ::47.834 -/com.example.linux.lrucachetest I/TextDownload: lrucache size:
- ::47.839 -/com.example.linux.lrucachetest I/MainActivity: run: Thread-
- ::47.895 -/com.example.linux.lrucachetest I/TextDownload: lrucache size:
- ::47.895 -/com.example.linux.lrucachetest I/MainActivity: hanlder handleMessage: main
LruCache缓存的原理分析
通过上述的案例,我们已经知道了LruCache的使用方法。接下来,我们一步步的分析它的过程以及原理。
一、 LruCache的文档描述如下:
A cache that holds strong references to a limited number of values. Each time a value is accessed, it is moved to the head of a queue. When a value is added to a full cache, the value at the end of that queue is evicted and may become eligible for garbage collection.
二、 它的属性一方法说明如下:
public class LruCache<K, V> {
private final LinkedHashMap<K, V> map;
/** Size of this cache in units. Not necessarily the number of elements. */
private int size;
private int maxSize; private int putCount;
private int createCount;
private int evictionCount;
private int hitCount;
private int missCount;
}
文档上一些对LruCache方法的描述:
If your cached values hold resources that need to be explicitly released, override entryRemoved(boolean, K, V, V)
If a cache miss should be computed on demand for the corresponding keys, override create(K). This simplifies the calling code, allowing it to assume a value will always be returned, even when there's a cache miss.
By default, the cache size is measured in the number of entries. Override sizeOf(K, V) to size the cache in different units. For example, this cache is limited to 4MiB of bitmaps:
三、 LruCache只有一个构造方法,LruCache(int maxSize)代码如下:初始化一个LinkedHashMap
public LruCache(int maxSize) {
if (maxSize <= 0) {
throw new IllegalArgumentException("maxSize <= 0");
}
this.maxSize = maxSize;
this.map = new LinkedHashMap<K, V>(0, 0.75f, true);
}
四、 LruCache的put方法是把内容放入到缓存中去,代码如下:
public final V put(K key, V value) {
if (key == null || value == null) {
throw new NullPointerException("key == null || value == null");
} V previous;
synchronized (this) {
putCount++;
size += safeSizeOf(key, value);
previous = map.put(key, value);
if (previous != null) {
size -= safeSizeOf(key, previous);
}
} if (previous != null) {
entryRemoved(false, key, previous, value);
} trimToSize(maxSize);
return previous;
}
其中safeSizeOf方法,是计算LruCache的已经缓存的大小,以下的sizeOf(默认返回1)方法是我们要重写的。
private int safeSizeOf(K key, V value) {
int result = sizeOf(key, value);
if (result < 0) {
throw new IllegalStateException("Negative size: " + key + "=" + value);
}
return result;
}
我们要重写sizeOf方法:
protected int sizeOf(K key, V value) {
return 1;
}
五、 LruCache的get方法是从缓存中去取得内容,代码如下:
public final V get(K key) {
if (key == null) {
throw new NullPointerException("key == null");
} V mapValue;
synchronized (this) {
// 如果根据相应的key得到value,就增加一次命中hitCount,并且返回结果
mapValue = map.get(key);
if (mapValue != null) {
hitCount++;
return mapValue;
}
// 否则增加一次missCount
missCount++;
} /*
* Attempt to create a value. This may take a long time, and the map
* may be different when create() returns. If a conflicting value was
* added to the map while create() was working, we leave that value in
* the map and release the created value.
*/
// 试图根据这个key,创建一个value。这里的create(key)默认是返回null,当然这个方法是可以重写的
V createdValue = create(key);
if (createdValue == null) {
return null;
} synchronized (this) {
createCount++;
// 如果我们重写了create(key)方法而且返回值不为空,那么将上述的key与这个返回值写入到map当中
mapValue = map.put(key, createdValue); if (mapValue != null) {
// There was a conflict so undo that last put
// 方法放入最后put的key,value值
map.put(key, mapValue);
} else {
size += safeSizeOf(key, createdValue);
}
} if (mapValue != null) {
// 这个方法也可以重写
entryRemoved(false, key, createdValue, mapValue);
return mapValue;
} else {
trimToSize(maxSize);
return createdValue;
}
}
六、 LruCache的remove方法是从缓存中去删除内容,并更新已经缓存的大小,代码如下:
public final V remove(K key) {
if (key == null) {
throw new NullPointerException("key == null");
} V previous;
synchronized (this) {
previous = map.remove(key);
if (previous != null) {
size -= safeSizeOf(key, previous);
}
} if (previous != null) {
entryRemoved(false, key, previous, null);
} return previous;
}
友情链接
android基础---->LruCache的使用及原理的更多相关文章
- android基础---->DiskLruCache的使用及原理
DiskLruCache是谷歌推荐的用来实现硬盘缓存的类,今天我们开始对于DiskLruCache的学习.DiskLruCache的测试代码:DiskLruCache的测试代码下载.关于FidkLru ...
- android基础---->JSON数据的解析
上篇博客,我们谈到了XML两种常用的解析技术,详细可以参见我的博客(android基础---->XMl数据的解析).网络传输另外一种数据格式JSON就是我们今天要讲的,它是比XML体积更小的数据 ...
- 基础4 Android基础
基础4 Android基础 1. Activity与Fragment的生命周期. Activity生命周期 打开应用 onCreate()->onStart()->onResume 按BA ...
- Android基础总结(8)——服务
服务(Service)是Android中实现程序后台运行的解决方案,它非常适合用于去执行哪些不需要和用户交互而且还要长期运行的任务.服务的运行不依赖任何用户界面,即使当程序被切换到后台,或者用户打开了 ...
- android基础---->IntentService的使用
这一篇博客,我们开始前台服务与IntentServie源码分析的学习,关于service的生命周期及其简单使用,请参见我的博客:(android基础---->service的生命周期) 目录导航 ...
- Android逆向系列文章— Android基础逆向(6)
本文作者:HAI_ 0×00 前言 不知所以然,请看 Android逆向-Android基础逆向(1) Android逆向-Android基础逆向(2) Android逆向-Android基础逆向(2 ...
- 图文详解 Android Binder跨进程通信机制 原理
图文详解 Android Binder跨进程通信机制 原理 目录 目录 1. Binder到底是什么? 中文即 粘合剂,意思为粘合了两个不同的进程 网上有很多对Binder的定义,但都说不清楚:Bin ...
- Android基础夯实--重温动画(三)之初识Property Animation
每个人都有一定的理想,这种理想决定着他的努力和判断的方向.就在这个意义上,我从来不把安逸和快乐看作生活目的的本身--这种伦理基础,我叫它猪栏的理想.--爱因斯坦 一.摘要 Property Anima ...
- Android基础新手教程——4.1.1 Activity初学乍练
Android基础新手教程--4.1.1 Activity初学乍练 标签(空格分隔): Android基础新手教程 本节引言: 本节開始解说Android的四大组件之中的一个的Activity(活动) ...
随机推荐
- contiki list 链表
1 相关宏和数据结构 1.1 LIST_CONCAT #define LIST_CONCAT2(s1, s2) s1##s2 #define LIST_CONCAT(s1, s2) LIST_CONC ...
- java-上传文件与现实上传文件
项目结构: 项目展示: 数据库: /* SQLyog Ultimate v12.09 (64 bit) MySQL - 5.5.53 : Database - fileupload ********* ...
- Js加密与解密
<html><head><META HTTP-EQUIV="MSThemeCompatible" CONTENT="Yes"> ...
- R笔记4:ggplot绘制商务图表--玫瑰图
我们说Excel有难度的图表,可以考虑ggplot2是否更方便,本帖的例子就是用ggplot做玫瑰图. Excel做玫瑰图有一定难度,可以使用雷达图或圆环图来构建,我的博客上曾有多个帖子讨论这个,见 ...
- 用 #include <filename.h> 格式来引用标准库的头文件
用 #include <filename.h> 格式来引用标准库的头文件(编译器将从 标准库目录开始搜索). #include <iostream> /* run this p ...
- unity3d绘画手册-------地形各个参数解释
关于Unity3D是什么.我就不多做解释了.由于工作原因,该系列原创教程不定期更新.每月必然有更新.谢谢各位. Unity地形:: 新建地形: <ignore_js_op> 如图在菜单中新 ...
- CentOS 7 Minimal编译安装MySQL5.6
写在前面,编译安装MySQL的优势:平台无关.可设定参数按需安装.安装的MySQL目录独立(方便清楚).更好的平台耦合及运行性能(很多运维的观点):缺点:编译安装较慢. 一.撤换系统防火墙 注:Cen ...
- CentOS显示设置时间命令- date
概要: date命令的功能是显示和设置系统日期和时间 命令格式: date [OPTION]... [+FORMAT]date [-u|--utc|--universal] [MMDDhhmm[[CC ...
- js中onclick中文参数传输方式
添加单引号或双引号即可,例: var type = "'"+n.bankCard.type+"'"; var number = "'"+n. ...
- c++ 转化
atof(将字符串转换成浮点型数)相关函数atoi,atol,strtod,strtol,strtoul表头文件#include定义函数double atof(const char *nptr);函数 ...