首页 > 解决方案 > 在 Java 中缓存地图

问题描述

我正在编写一个 methodA(),它通过访问 Amazon S3 中的对象返回一个 Map<String, String> ,并且这个方法每小时会被调用几次(大约数千次)。我想每天(而不是每次方法调用)都从 S3 获取对象,并将此映射保存在本地缓存中以供所有方法调用使用。我的方法应该是什么?

标签: javaamazon-s3caching

解决方案


A map can solve this issue but you also have to make sure to evict your cache if necessary.

If you more than one instance of your application you should maybe think about a shared cache i.e. a redis database.


推荐阅读