1. Guava Cache:
2. Caffeine:
3. Ehcache:
4. Redis:
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
public class CacheExample {
private ConcurrentLinkedHashMap<String, Object> cache;
public CacheExample() {
this.cache = new ConcurrentLinkedHashMap.Builder<String, Object>()
.maximumWeightedCapacity(100)
.build();
}
public Object getFromCache(String key) {
return cache.get(key);
}
public void putToCache(String key, Object value) {
cache.put(key, value);
}
public void removeFromCache(String key) {
cache.remove(key);
}
}