# jakewharton/disklrucache

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/jakewharton-disklrucache).**

5,783 stars · 1,163 forks · Java · Apache-2.0 · archived

## Links

- GitHub: https://github.com/JakeWharton/DiskLruCache
- Homepage: http://jakewharton.github.io/DiskLruCache
- awesome-repositories: https://awesome-repositories.com/repository/jakewharton-disklrucache.md

## Description

DiskLruCache is a disk-backed key-value cache library for Android and Java environments that stores data on the filesystem within a configurable byte limit. It uses a least-recently-used (LRU) eviction policy to automatically remove old entries when the cache exceeds its allocated size, and maintains a journal file to reconstruct its in-memory state after a process restart.

The cache provides atomic write operations that first write new data to a temporary file before atomically renaming it, preventing partial or corrupted reads during concurrent access. It returns frozen snapshots of cache entries at read time, ensuring consistency even if the entry is later modified. Each entry requires a monotonically increasing version number, enabling detection of stale or concurrent modifications.

Cached byte sequences can be accessed as input streams or file references, decoupling consumption from the underlying storage format. The library enforces per-entry byte size tracking to trigger eviction during writes, using a doubly linked list to track access order.

## Tags

### Data & Databases

- [Bounded Disk Cache Allocations](https://awesome-repositories.com/f/data-databases/data-buffering/byte-buffers/bounded-disk-cache-allocations.md) — Enforces a configurable disk byte limit with per-entry size tracking and automatic eviction.
- [Strongly Consistent Cache Reads](https://awesome-repositories.com/f/data-databases/data-engineering-infrastructure/caching-performance/caching-strategies/query-result-caching/cache-consistency-managers/strongly-consistent-cache-reads.md) — Returns frozen snapshots of cache entries at read time, ensuring consistency despite concurrent modifications.
- [Disk-Backed Implementations](https://awesome-repositories.com/f/data-databases/data-engineering-infrastructure/caching-performance/caching/least-recently-used-caches/disk-backed-implementations.md) — Implements a disk-backed LRU cache with bounded size and automatic eviction.
- [Bounded Disk Cache Allocations](https://awesome-repositories.com/f/data-databases/high-throughput-decompression/bounded-memory-decompression/memory-bounded-caching/bounded-disk-cache-allocations.md) — Enforces a configurable disk byte limit with per-entry size tracking and automatic eviction.
- [General Purpose Disk Caches](https://awesome-repositories.com/f/data-databases/in-memory-caches/android-media-caching/general-purpose-disk-caches.md) — Provides a general-purpose disk-backed LRU cache for Android applications.
- [Bounded Disk Key-Value Stores](https://awesome-repositories.com/f/data-databases/in-memory-data-stores/disk-backed-stores/bounded-disk-key-value-stores.md) — Stores key-value pairs on disk within a bounded byte limit with automatic eviction. ([source](https://cdn.jsdelivr.net/gh/jakewharton/disklrucache@master/README.md))
- [Key-Value Persistence Stores](https://awesome-repositories.com/f/data-databases/key-value-persistence-stores.md) — Persists key-value data to the filesystem within a configurable size limit, evicting old entries when full.
- [Cache Snapshot Isolations](https://awesome-repositories.com/f/data-databases/strict-serializability/serializable-snapshot-isolation/cache-snapshot-isolations.md) — Returns frozen snapshots of cache entries at read time, ensuring consistency despite concurrent modifications.
- [Concurrency Versioning](https://awesome-repositories.com/f/data-databases/database-versioning/record-state-versioning/concurrency-versioning.md) — Requires monotonically increasing version numbers per entry to detect stale modifications.

### Development Tools & Productivity

- [Entry Versioning Guards](https://awesome-repositories.com/f/development-tools-productivity/version-management/agent-versioning/versioned-memory-repositories/versioned-dll-repositories/versioned-patch-caches/entry-versioning-guards.md) — Requires monotonically increasing version numbers per entry to detect stale or concurrent modifications.
- [Stream-Based File Access Abstractions](https://awesome-repositories.com/f/development-tools-productivity/remote-file-transfers/remote-file-reading/remote-file-stream-readers/stream-based-file-access-abstractions.md) — Returns cached byte sequences as input streams or file references for flexible consumption. ([source](https://cdn.jsdelivr.net/gh/jakewharton/disklrucache@master/README.md))

### Programming Languages & Runtimes

- [Disk-Backed Caches](https://awesome-repositories.com/f/programming-languages-runtimes/java-utility-libraries/disk-backed-caches.md) — Provides a Java implementation of a disk-backed cache with atomic read and write operations.

### Security & Cryptography

- [Cache Snapshot Isolations](https://awesome-repositories.com/f/security-cryptography/isolated-dom-reading/cache-snapshot-isolations.md) — Returns frozen snapshots of cache entries at read time for consistency.

### Software Engineering & Architecture

- [Atomic File Writes](https://awesome-repositories.com/f/software-engineering-architecture/atomic-file-writes.md) — Writes cache entries atomically by writing to a temporary file then renaming, preventing corruption.
- [LRU Cache Eviction](https://awesome-repositories.com/f/software-engineering-architecture/memory-management/lru-cache-eviction.md) — Implements LRU eviction on disk using a linked list to track access order.
- [Disk-Backed LRU Evictions](https://awesome-repositories.com/f/software-engineering-architecture/memory-management/lru-cache-eviction/disk-backed-lru-evictions.md) — Stores bounded byte-sequence values on disk with automatic LRU eviction. ([source](https://cdn.jsdelivr.net/gh/jakewharton/disklrucache@master/README.md))
- [Linked-List LRU Evictions](https://awesome-repositories.com/f/software-engineering-architecture/memory-management/lru-cache-eviction/linked-list-lru-evictions.md) — Uses a doubly linked list to track access order and evicts the least-recently-used entry.
- [Stream Abstractions](https://awesome-repositories.com/f/software-engineering-architecture/stream-abstractions.md) — Exposes cached byte sequences as input streams or file references for flexible consumption.

### System Administration & Monitoring

- [Cache Journal Logs](https://awesome-repositories.com/f/system-administration-monitoring/log-ingestion/journal/cache-journal-logs.md) — Maintains a journal file to reconstruct cache state after process restarts.
- [Cache Recovery Journals](https://awesome-repositories.com/f/system-administration-monitoring/log-ingestion/journal/cache-recovery-journals.md) — Maintains a journal file to reconstruct cache state after process restarts.
