Caching a Map in Java

Viewed 48

I am writing a methodA() which returns a Map<String, String> by accessing an object in Amazon S3 and this method will be called several times (in the order of thousands) every hour. I want to get the object from S3 every day (and not for every method call) and maintain this map in a local cache for all the method calls. What should my approach be ?

1 Answers

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.

Related