开发者

caching a database into an array which refreshes every 5 minutes

I need to cache a database into an array using Java, what is the best way to do this?

I need this array to refresh every 5 mi开发者_C百科nutes and I need to be able to query the array.

I'm looking to use two arrays and Some form of DAO DTO implementation.

Are there any set frameworks for this?


Some key points to make your life easier:

  1. Use the singleton pattern for your cached data serivce
  2. Use a scheduled executor to periodically refresh the data
  3. Make sure the refresh is atomic - consider using an AtomicReference to hold the data


you can use ehcache for this, you need to configure your DAO DTO implementation to cache its results & lookup results from the cache...

you can achieve the cache refresh by configuring the eviction time (time period for the cache to be cleared).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜