Android的对象缓存 [英] Android Objects Cache

查看:120
本文介绍了Android的对象缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找一个简单的开源非copyleft的缓存为Android(SDK 7+)类。

Looking for a simple open source non-copyleft caching for Android (SDK 7+) class.

的目的是主要的存储位图取值取出异步(所以我不需要这个功能包含在缓存类)。

The purpose is primary to store the Bitmaps fetched asynchronously (so i don't need this functionality to be included in the cache class).

我使用的是weakList为了这个目的,那自然是一个不错的解决方案,与番石榴缓存是一个更好一点,但仍然不精。

I was using a weakList for this purpose, that was naturally a bad solution, with Guava cache that is a little better but still not fine.

这是preferred高速缓存可以存储任何可序列化对象,不只是一个位图,而且我可以很容易地清除使用的某些标记的对象,而对象添加到缓存中。

It's preferred that the cache is able to store any serializable Object, not just a Bitmap, and that i could easily purge the objects of certain tag used while the object is added to cache.

最好的办法是让文件系统缓存像包裹SQLite数据库。 这将是巨大的,如果缓存将由设置&gt被清除;管理用途>清除缓存

The best option would be to get the filesystem cache like wrapping the sqlite database. It would be great if the cache would be cleared by Settings >Manage Application > Clear Cache

推荐答案

以上纯LruCache建议是在内存中缓存。从你的问题听起来好像你正在寻找一个磁盘缓存解决方案。

The plain LruCache suggested above is an in memory cache. From your question it sounds like you are looking for a disk cache solution.

阅读磁盘缓存高速缓存位图的android培训文档的

Read the Disk Cache of the Caching Bitmaps android training doc.

然后看看在DiskLruCache执行以下主题进行讨论: <一href="http://stackoverflow.com/questions/10185898/using-disklrucache-in-android-4-0-does-not-provide-for-opencache-method">Using DiskLruCache在安卓4.0不提供openCache方法

Then take a look at the DiskLruCache implementation discussed on the following thread : Using DiskLruCache in android 4.0 does not provide for openCache method

您可以抢在GitHub上 DiskLruCache 源。

You can grab the DiskLruCache source on GitHub.

这篇关于Android的对象缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆