【问题标题】:What is the best way to store often used (not changeable) List, Map?存储常用(不可更改)列表、地图的最佳方式是什么?
【发布时间】:2013-06-28 02:26:09
【问题描述】:

存储常用(不可更改)列表、地图的最佳方式是什么?
使用@Cacheable 优于在@PostConstruct 的服务层中创建列表更好吗?

【问题讨论】:

    标签: java spring caching spring-mvc ehcache


    【解决方案1】:

    我会说@Cacheable 更好,因为您不受特定缓存实现的约束。此外,它对代码的侵入性也较小。正如Spring Reference Manual Section 29.3.1 中所述,缓存一个按 ISBN 查找图书的方法如下所示:

    @Cacheable("books")
    public Book findBook(ISBN isbn) {...}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-21
      • 1970-01-01
      • 2013-06-14
      • 1970-01-01
      • 1970-01-01
      • 2013-05-23
      相关资源
      最近更新 更多