DiskLruCache
Java implementation of a Disk-based LRU cache which specifically targets Android compatibility.
DiskLruCache is a Java library that saves data to the device filesystem and keeps the total size of that data within a limit you set. When stored data exceeds the limit, the library automatically removes old entries in the background until it fits again. The entries it removes are the ones that have not been accessed recently, which is the meaning of LRU (least recently used).
This kind of cache is useful in Android apps when you want to avoid re-downloading or re-computing expensive data on every launch. Instead, you store the result the first time, and on the next run you read it from disk rather than fetching it again. The README notes that the implementation specifically targets Android compatibility.
Each item in the cache is identified by a string key. You store values as raw byte sequences, which means you can cache anything from downloaded images to JSON responses to computed results. Reading a cache entry gives you a snapshot of the data at the moment you requested it; any updates happening at the same time do not affect your read. Writing is atomic too: if you commit a change, readers will see either the old data or the new data, never a partially written mix.
The library handles some types of filesystem errors gracefully. If a cached file goes missing, the library drops that entry and moves on. Write errors fail without crashing your application.
The library is available through Maven and Gradle for standard Java and Android projects. It is authored by Jake Wharton and based on an original implementation from the Android Open Source Project. It is released under the Apache 2.0 license.