开发者

Eclipselink caching problem (one database for two systems)

开发者 https://www.devze.com 2023-04-01 19:20 出处:网络
I have two online-systems running. Both of them are using eclipselink. The first system is a administration-system, where the prices for the second application are managed.

I have two online-systems running. Both of them are using eclipselink.

The first system is a administration-system, where the prices for the second application are managed. The second system is a online shop, where customer can buy articles. Both of them run on the same server and use the same oracle dat开发者_JAVA百科abase.

To provide a fast access, the price-objects are cached by eclipselink.

If I change the value of a price in the administration-system, the shop-system should flush its cache in order to get the new price value. What is the best way to solve this problem?


I have a similar problem but it's with user credentials.

1) Configure caching in the shop-side

You can configure the EclipseLink caching to have an expiry. You can configure it to have a TimeToLive or an expire at value. For example you could configure prices to expire after 1, 5 or 10 minutes. Not instant, but pretty quick and very easy to implement. Check out the @Cache annotation in EclipseLink. This is what I ended up using.

2) Have the admin application communicate with the shop application

It might be worth creating a web-service that lives in the shop side which will invalidate the cache when called. Kinda fragile but might be necessary depending on your setup.

3) Use Cache co-ordination

EclipseLink has functionality for cache co-ordination. I have never used it but it looks like it might be best policy for you. You can check out the EclipseLink documentation for more information.

0

精彩评论

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

关注公众号