3

I have used the cache2k in my java project and it was so simple (key-value pair) and easy to use. Now I want to know is if cache2k is a persistent or non-persistent cache.

I found the answer in here https://stackoverflow.com/a/23709996/12605243 which was said at 2014 stated that it was gonna be updated to persistent cache.

So my question is 'Am I using a persistent or non persistent cache?'. I have read their docs but unable to find it.

Nicktar
  • 5,548
  • 1
  • 28
  • 43
Stack Kiddy
  • 556
  • 1
  • 4
  • 10
  • From faintly looking through multiple posts on Stackoverflow (under the search term: cache2k persistent) and reading through the Java docs, I can read that currently there is no real persistent cache support for cache2k. As the website also states: "In-memory cache" and the Java Documentation (for Cache#clearAndClose) which states: "This method is to future proof the API, when a persistence feature is added". Maybe use the rule of thumb: "If it's presented, assume it won't have it." – Remco Buddelmeijer Feb 24 '20 at 07:56

1 Answers1

0

Basically its possible to add persitence via CacheLoader and CacheWriter. We use that in several ways to use file system or database as storage. When adding persistence this way the cache operates in the so called "cache through" mode. Some operations of the cache, especially get and put operate transparently and read or write the data via the loader and writer to the storage. Other operations, like CAS operations, just interact with the in-memory cache.

The persistence feature as it was planed was meant to be transparent for all cache operations. Although its feasible and the basic work is done in the internal infrastructure, we don't have a big need for it. Other features and tasks seem more important. However, I am happy to hear about potential use cases.

cruftex
  • 5,545
  • 2
  • 20
  • 36
  • Here is one use case for you :) We have machines that simply get their power plug pulled. As i need a cache for something right now, i find that there really is no free / open source cache library right now which persists to disk. – wlfbck Jun 28 '21 at 08:11
  • Forgot to add: I could use a DB, but that comes with all the hassle of using one, and i also need expiry, which caches just always 'have'. – wlfbck Jun 28 '21 at 08:32