DiskLruCache
DiskLruCache copied to clipboard
Java implementation of a Disk-based LRU cache which specifically targets Android compatibility.
what can cause cache is closed?
I am using this cache to store many many small files. I set a max of 256MB but the cache grows up to more than 450MB. That's because each small...
Hello guys, I use DiskLruCache in a multi-thread environment. I get an infinite loop in the trimToSize method: while (size > maxSize) { Map.Entry toEvict = lruEntries.entrySet().iterator().next(); remove(toEvict.getKey()); } The...
If called while another editor is in use edit will return null. I had a hard time debugging this. Throwing a ConcurrentModificationException or something similar would be better. see DiskLruCache...
We're using DiskLruCache in a serverside app that downloads images from a remote server. When two requests simultaneously want to store the same image in the cache, the code gets...
This version still have leakage issue: 09-09 21:47:38.549 31155 31164 E StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource...
In FAT filesystem, which is the default filesystem for external SD Card, we can only store around 15 ~ 20k files in a directory. In most cases, it shouldn't be...
``` java DiskLruCache.Editor editor = getDiskCache().edit(key); try { File file = editor.getFile(0); new FileOutputStream(file).write(data); editor.commit(); } finally { editor.abortUnlessCommitted(); } ``` Now, `commit` calls `completeEdit` which has a line `dirty.renameTo(clean);`...
Applications may need to explicitly request a disk cache cleanup in some circumstances. For example in our application we detect if the device hits an exception due to being very...
Calling `get( key )` can be too expensive in some cases as a check if something is in the cache. Providing a light weight, (_non-synchronized?_) way of checking if a...