简体   繁体   English

存储常用(不可更改)列表,地图的最佳方法是什么?

[英]What is the best way to store often used (not changeable) List, Map?

What is the best way to store often used (not changeable) List, Map? 存储常用(不可更改)列表,地图的最佳方法是什么?
Is it better to use @Cacheable over creating list in the service layer on @PostConstruct ? 使用@Cacheable不是在@PostConstruct的服务层中创建列表更好吗?

I would say @Cacheable is better because you're not tied to a specific caching implementation. 我会说@Cacheable更好,因为您不依赖于特定的缓存实现。 Also it's less intrusive on the code. 另外,它对代码的干扰也较小。 As specified on Spring Reference Manual Section 29.3.1 , caching a method that finds a book by ISBN just looks like this: 正如Spring参考手册第29.3.1节中所指定的那样 ,缓存一种通过ISBN查找书籍的方法如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将通用列表存储在 Map 值中的最佳方法是什么? - What is the best way to store a generic List in a Map value? 无法使用数据库时存储数据的最佳方法是什么? - What is the best way to store data when a database could not be used? 在自动化中存储执行期间使用的 sql 查询的最佳方法是什么 - What is the best way to store the sql queries used during execution in Automation 将 state 的历史记录和支出作为列表存储在 Java 中的最佳方式是什么 - What is the best way to store history of state and payout as a list in Java 根据值映射验证 JsonNode 列表的最佳方法是什么? - What is the best way to validate a List of JsonNodes against a Map of values? 存储字符串列表的最佳方法 - best way to store a list of strings 简洁存储常用方法的最佳方法 - Best way to concisely store frequently used methods 将文本数据存储在一个或多个文件中以便可以在各种平台上使用的最佳方法是什么? - What is the best way to store text data in a file/files so it can be used in various platforms? 将复杂密钥存储在 map 中的最佳方法? - Best way to store a complex key in a map? 在数据库中存储堆栈跟踪的最佳方法是什么 - What is the best way to store stacktrace in database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM