java缓存 - 在使用Map和使用Graph之间进行选择

时间:2016-10-28 12:54:53

标签: java spring caching google-guava-cache

在我的java Spring应用程序中,我需要构建一些配置元数据的进程内/内存缓存,其结构如下:

Graph<String customerName, Map<String, JSONObject> customerMetadata>:

  "My Customer" "CustomerInfo":
                    {IngestionConfig:  {"data": "schema":{"fields"[]}}}
                "Asset"
                    {IngestionConfig:  {"data": "schema":{"fields"[]}}}
                "Invoice"
                    {IngestionConfig:  {"data": "schema":{"fields"[]}}}

问题:

哪种技术更适合此目的:地图,Google Guava的ValueGraph,EhCache或其他?

1 个答案:

答案 0 :(得分:1)

这取决于。您希望缓存在一段时间后自动到期吗?你需要分发你的地图吗?它是只读的还是您计划更新它的运行时间?如果它不是只读的,您的环境是单线程还是多线程? 如果你不需要任何这些花里胡哨的东西,如果它只读它,我宁愿选择Map(或任何用Java填充的东西)。 (这只是一种观点 - 我是一个极简主义者。)