https://github.com/cache2k/cache2k
Lightweight, high performance Java caching
https://github.com/cache2k/cache2k
android android-library cache java java-library
Last synced: 6 days ago
JSON representation
Lightweight, high performance Java caching
- Host: GitHub
- URL: https://github.com/cache2k/cache2k
- Owner: cache2k
- License: apache-2.0
- Created: 2013-12-18T17:25:04.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2025-07-22T12:34:48.000Z (5 months ago)
- Last Synced: 2025-07-22T14:37:28.952Z (5 months ago)
- Topics: android, android-library, cache, java, java-library
- Language: Java
- Homepage: http://cache2k.org
- Size: 9.96 MB
- Stars: 735
- Watchers: 23
- Forks: 75
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-java - Cache2K
README
[](https://www.apache.org/licenses/LICENSE-2.0.html)
[](https://stackoverflow.com/questions/tagged/cache2k)
[](https://maven-badges.herokuapp.com/maven-central/org.cache2k/cache2k-core)
[](https://circleci.com/gh/cache2k/cache2k/tree/master)
# cache2k Java Caching
cache2k is an in-memory high performance Java Caching library.
````java
Cache cache = new Cache2kBuilder() {}
.expireAfterWrite(5, TimeUnit.MINUTES) // expire/refresh after 5 minutes
.setupWith(UniversalResiliencePolicy::enable, b -> b // enable resilience policy
.resilienceDuration(30, TimeUnit.SECONDS) // cope with at most 30 seconds
// outage before propagating
// exceptions
)
.refreshAhead(true) // keep fresh when expiring
.loader(this::expensiveOperation) // auto populating function
.build();
````
For a detailed introduction continue with [Getting Started](https://cache2k.org/docs/latest/user-guide.html#getting-started).
## Features at a glance
* Small jar file (less than 400k) with no external dependencies
* Fastest access times, due to non blocking and wait free access of cached values, [Blog article](https://cruftex.net/2017/09/01/Java-Caching-Benchmarks-Part-3.html)
* Pure Java code, no use of `sun.misc.Unsafe`
* Thread safe, with a complete set of [atomic operations](https://cache2k.org/docs/latest/user-guide.html#atomic-operations)
* [Resilience and smart exception handling](https://cache2k.org/docs/latest/user-guide.html#resilience)
* Null value support, see [User Guide - Null Values](https://cache2k.org/docs/latest/user-guide.html#null-values)
* Automatic [Expiry and Refresh](https://cache2k.org/docs/latest/user-guide.html#expiry-and-refresh): duration or point in time, variable expiry per entry, delta calculations
* CacheLoader with blocking read through, see [User Guide - Loading and Read Through](https://cache2k.org/docs/latest/user-guide.html#loading-read-through)
* CacheWriter
* [Event listeners](https://cache2k.org/docs/latest/user-guide.html#event-listeners)
* [Refresh ahead](https://cache2k.org/docs/latest/user-guide.html#refresh-ahead) reduces latency
* [Low Overhead Statistics](https://cache2k.org/docs/latest/user-guide.html#statistics) and JMX support
* [Separate API](https://cache2k.org/docs/latest/apidocs/cache2k-api/index.html) with stable and concise interface
* [complete JCache / JSR107 support](https://cache2k.org/docs/latest/user-guide.html#jcache)
* [XML based configuration](https://cache2k.org/docs/latest/user-guide.html#xml-configuration), to separate cache tuning from logic
## Integrations
* [Spring Framework](https://cache2k.org/docs/latest/user-guide.html#spring)
* [Scala Cache](https://github.com/cb372/scalacache)
* Datanucleus (via JCache)
* Hibernate (via JCache)
## More...
For more documentation and latest news, see the [cache2k homepage](https://cache2k.org).
## Contributing
See the [Contributor Guide](CONTRIBUTING.md).