Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

2-level cache in java

Tags:

java

caching

How can I organize a 2 level cache in Java?

  • 1st level - memory
  • 2nd level - filesystem

Where I can find information about 2 level cache implementation and cache strategies configuration or can you show me any methods that can solve this problem.

like image 674
BraginiNI Avatar asked Oct 24 '22 21:10

BraginiNI


1 Answers

I suggest using imcache and load necessary items from disk using cache loader as follows,

Cache<String,Object> yourCache = CacheBuilder.
   concurrentHeapCache().cacheLoader(new CacheLoader<String, Object>() {
   public Object load(String key) {
   //code to load item from file.
   }
}).build();  
like image 191
yusufaytas Avatar answered Nov 11 '22 06:11

yusufaytas