0

I have a case where I need to frequently update and retrieve values of a map. This variable should have the same keys and values throughout all four servers. If one server updates the Map, it should be reflective in the other servers.

I believe I should be caching this..

Can I have some example codes in how I should be achieving this ?

Thank you.

adbar
  • 438
  • 1
  • 8
  • 18

2 Answers2

0

You need a distributed cache. Choosing one is another issue... see here.

Example of using EhCache - here.

T. Josef
  • 21
  • 3
0

I would suggest to use any distributed cache for it, i.e. Hazelcast implementation for distributed map You could setup a Hazelcast cluster and implement MapStore

Also you will need to configure Hazelcast clients on each tomcat server. This clients will load distributed map and take care of syncing the data.

Hazelcast has a great documentation and plenty of examples so it should be easy for you to deal with it.

Aliaksei Stadnik
  • 1,692
  • 3
  • 15
  • 32