Saving many objects using Java

I am referring to the community here to see if there is a way to store many objects in a Java map structure (> 500K). I know that at some point my application will exceed the amount of memory if I use the Java Collection API and I am looking for other solutions (outside of distributed caching). My intention is to store something with the effect of Map <String, List <String β†’.

Requirements:

  • The structure will be unchanged (single loading onto a card). Primary read access.
  • Access to the map should be fairly quick, but not requiring a low-latency search, more concerned with storing and storing these objects in memory.

Does anyone know of a library that I can use that can achieve this, or has anyone ever come across a solution in which they had to load many objects in memory in Java? I would be very interested to hear your feedback.

Thanks.

+4
source share
3 answers

EhCache would be ideal for this. In the most basic version, it offers a card with a key, with additional overflow to disk and the optional permanent reboot of the JVM. It will store the items in memory that are most commonly used.

+10
source

I'm with a scaffman. In addition to overflowing to disk, EhCache offers you to put the cache in the process, but not in a heap. If your cache is really large, this can have a very positive effect on performance, as it reduces the load on the GC.

This particular function, however, must be paid for, but otherwise EhCache is free.

Instead of Java EhCache, there are several other caches that offer similar or sometimes even more advanced options, such as Infinispan or OsCache.

+1
source

You read a read-only database like java cdb: http://www.strangegizmo.com/products/sg-cdb/

+1
source

Source: https://habr.com/ru/post/1344177/


All Articles