Search code examples
javaehcacheehcache-bigmemoryehcache-3

How to store a nested Map structure in Ehcache?


I want to store a Variable of type Map < Integer, Map < String, Map < String, Integer >>> into Ehcache. How to store this nested Map structure in Ehcache as a value?


Solution

  • Ehcache 3 can only store java.io.Serializable objects. Map is an Interface which is not serializable but the HashMap instance of the Map interface implements java.io.Serializable interface. Thus you can configure your Cache as Cache<Integer, HashMap<String, HashMap<String, Integer>>>.