# ben-manes/caffeine

**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/ben-manes-caffeine).**

17,491 stars · 1,684 forks · Java · apache-2.0

## Links

- GitHub: https://github.com/ben-manes/caffeine
- awesome-repositories: https://awesome-repositories.com/repository/ben-manes-caffeine.md

## Description

Caffeine is a high-performance caching library for the Java virtual machine designed to manage object lifecycles within the application heap. It functions as a thread-safe, memory-resident data store that reduces latency by keeping frequently accessed objects available for immediate retrieval.

The library distinguishes itself through a sophisticated eviction strategy that balances recency and frequency to determine which entries to retain. It utilizes a frequency-based admission policy to evaluate the historical access patterns of new data, ensuring that the cache remains populated with the most relevant information. To maintain high throughput under concurrent access, the system employs lock-free event processing and segmented storage to minimize contention.

Beyond its core storage capabilities, the library provides automated mechanisms for data loading and entry eviction based on size, time, or reference strength. It also includes built-in support for monitoring and observability, allowing developers to track hit and miss rates alongside eviction counts to inform memory management decisions.

## Tags

### Data & Databases

- [Caching Libraries](https://awesome-repositories.com/f/data-databases/data-governance-modeling/data-management-governance/database-infrastructure-components/caching-libraries.md) — Provides a high-performance caching library for the Java virtual machine with automatic eviction and data loading.
- [Concurrent Caches](https://awesome-repositories.com/f/data-databases/concurrent-write-optimizations/concurrent-caches.md) — Provides a thread-safe data structure designed for high-concurrency environments to manage object lifecycles.
- [In-Memory Data Stores](https://awesome-repositories.com/f/data-databases/in-memory-data-stores.md) — Functions as a memory-resident storage mechanism that reduces application latency by caching objects in the heap. ([source](https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/2.5.5/index.html))
- [Automatic Cache Loaders](https://awesome-repositories.com/f/data-databases/automatic-cache-loaders.md) — Populating cache entries automatically when a requested key is missing by executing a provided function to fetch the required value.
- [Caching](https://awesome-repositories.com/f/data-databases/data-engineering-infrastructure/caching-performance/caching.md) — Caches frequently accessed data in memory to improve application performance by avoiding repeated expensive lookups. ([source](https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine))
- [In-Memory Caches](https://awesome-repositories.com/f/data-databases/in-memory-caches.md) — Stores frequently accessed objects in the application heap to reduce latency and avoid redundant computations.
- [In-Memory Caching](https://awesome-repositories.com/f/data-databases/dataset-management-tools/in-memory-caching.md) — Maintains in-memory caches to reduce latency and improve application performance. ([source](https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/3.0.1/index.html))
- [Lazy Expiration](https://awesome-repositories.com/f/data-databases/database-record-management/expired-record-purging/lazy-expiration.md) — Cleans up expired entries during access to avoid background thread overhead and latency spikes.
- [Hash Tables](https://awesome-repositories.com/f/data-databases/hash-tables.md) — Organizes data into multiple independent hash segments to reduce lock contention and allow parallel access.

### Software Engineering & Architecture

- [Frequency-Based Admission](https://awesome-repositories.com/f/software-engineering-architecture/cache-eviction-strategies/frequency-based-admission.md) — Uses a frequency-based sketch to decide whether new entries deserve a spot in the cache based on historical access patterns.

### User Interface & Experience

- [Cache Eviction Policies](https://awesome-repositories.com/f/user-interface-experience/presentation-frameworks/lifecycle-state-management/component-lifecycle-management/cache-eviction-policies.md) — Removes cache items automatically based on size limits, time-based expiration, or reference strength. ([source](https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/3.0.5/index.html))

### Operating Systems & Systems Programming

- [Lock-Free Buffers](https://awesome-repositories.com/f/operating-systems-systems-programming/kernel-core-internals/process-and-memory-management/memory-management/buffer-and-cache-management/binary-buffer-managers/trace-buffer-managers/lock-free-buffers.md) — Buffers high-frequency write operations into a lock-free queue to minimize contention and maintain high throughput.

### Web Development

- [On-Demand Loaders](https://awesome-repositories.com/f/web-development/data-fetching-caching/on-demand-loaders.md) — Populates cache entries automatically when a requested key is missing by executing a provided function. ([source](https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/3.0.5/index.html))

### System Administration & Monitoring

- [Cache Performance Metrics](https://awesome-repositories.com/f/system-administration-monitoring/monitoring-and-observability/observability-platforms/metric-performance-monitors/cache-performance-metrics.md) — Tracks hit and miss rates alongside eviction counts to gain visibility into memory usage and performance. ([source](https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/3.1.8/index.html))
