Iceglaze
Iceglaze

Reputation: 349

Use Guava Cache to persist data to a hard disk

I am new to Guava Cache. How do I create the following in the cache?

  1. Save the data in memory as normal.
  2. When the size of the cache is over the given number, it will persist the data in cache in a configurable file on the hard disk.

Upvotes: 9

Views: 15136

Answers (2)

Enno Shioji
Enno Shioji

Reputation: 26882

The API (and the feature set) is a bit heavy weight but I've used Ehcache in the past and it worked well. Similar technologies include Infinispan and Hazelcast.

I don't like the solution in the article Chris shared as performance and the storage limit will depend on the file system you run on (and won't be particularly good), and it also lacks protection against corruption etc. If you plan to use it in production, I'd use one of these libraries.

Upvotes: 5

Chris
Chris

Reputation: 410

This will probably be helpful: Extending Guava caches to overflow to disk

Upvotes: 11

Related Questions