GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Android-Note/Java/LruCache.md at master · YeeLL/Android-Note

Expand file tree

/

LruCache.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
25 lines (21 loc) · 683 Bytes
/

LruCache.md

Copy path

File metadata and controls

25 lines (21 loc) · 683 Bytes
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

LruCache

LruCache是Android内存缓存的一种机制,全称 Lru 最近最少使用算法。 这种缓存机制就是将最近最少使用的数据清除以腾出空间: Android例子: Android中初始化LruCache需要给他分配一定的控件,一般情况下分配整个APP内存的8分之一。 代码:

LruCache<String,Bitmap> lru = new LruCache<String,Bitmap>(memClass){
    @Override
    protected int sizeOf(String key, Bitmap value) {
       return value.getByteCount()/1024;
    }
};

存:
lru.put(String,key);
取:
lru.get(String);

LruCache实现原理

LruCache 内部是使用LinkedHashMap 实现的。

LinkedHashMap

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.