I have some data selected from database and cached in memory.I use them quite frequently.But sometimes I need to update this data,and I don't want to stop the server.Is there any available solutions for this?
Asked
Active
Viewed 271 times
0
-
Have you checked if you can refresh the data in your cache? – Luiggi Mendoza May 28 '14 at 05:56
-
I am worried about there might be some read-write concurrent issues. – LouisCheung May 28 '14 at 06:17
-
If you're manually caching the data, then you **should not** do it again and use a third party library that already handles this scenario like ehcache or infinispan. – Luiggi Mendoza May 28 '14 at 06:18
-
Sometimes I don't know which element of cache need to be updated.I need to reload all of it from database,but I can't shutdown the service? – LouisCheung May 28 '14 at 06:47
1 Answers
0
You could use a DB cache (Try using Ehcache, it supports JDBC caching).
Or provide some external interface that you can send a message to, to tell you app to update from the DB.

Scary Wombat
- 44,617
- 6
- 35
- 64
-
Sometimes I don't know which element of cache need to be updated.I need to reload all of it from database,but I can't shutdown the service? – LouisCheung May 28 '14 at 06:41
-
I mean if I can make 2 copies of it,and hot swap the cache totally.Is there any available third party library could do this? – LouisCheung May 28 '14 at 06:42
-