Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for simple Java in-memory cache [closed]

Tags:

java

caching

I'm looking for a simple Java in-memory cache that has good concurrency (so LinkedHashMap isn't good enough), and which can be serialized to disk periodically.

One feature I need, but which has proved hard to find, is a way to "peek" at an object. By this I mean retrieve an object from the cache without causing the cache to hold on to the object any longer than it otherwise would have.

Update: An additional requirement I neglected to mention is that I need to be able to modify the cached objects (they contain float arrays) in-place.

Can anyone provide any recommendations?

like image 391
sanity Avatar asked Feb 22 '09 20:02

sanity


People also ask

What is in memory cache in Java?

But what is “Cache?” A cache is an area of local memory that holds a copy of frequently accessed data that is otherwise expensive to get or compute. Examples of such data include a result of a query to a database, a disk file or a report. Lets look at creating and using a simple thread-safe Java in-memory cache.

Does Java have a cache?

The Java Object Cache provides caching for expensive or frequently used Java objects when the application servers use a Java program to supply their content. Cached Java objects can contain generated pages or can provide support objects within the program to assist in creating new content.


1 Answers

Since this question was originally asked, Google's Guava library now includes a powerful and flexible cache. I would recommend using this.

like image 101
sanity Avatar answered Oct 22 '22 12:10

sanity