views:

31

answers:

2

Hello,

Scenario is how to cache on server if we have a page which show Categories Listing including no of items in it like this

CategoryA(40 posts) CategoryB(100 post) and so on when ever a visitor come to this page this information will be fetched from Database. That's what we don't want Actually what we want is to Cache this page for 15minutes so when ever next request come it will not hit Database and serve this cache. This cache can reside in RAM or on disk as file

This thing is pretty easy in asp.net but don't find a way to implement it in java/spring web mvc

Can anyone let us know how to implement this using Spring WEB MVC framework

Thanks In Advance!

+2  A: 

I hope you haven't put all that logic in your web controllers. There ought to be a separate service tier that the web tier calls.

Put that cache in the service that the web tier talks to. Have it check the cache before calling the database.

duffymo
+1  A: 

I would recommend considering a caching server such as Ehcache to cache your data, instead of a home-brew solution.

Ehcache can be used in-process or made resident on your existing server. A separate project called ehcache-spring-annotations exists to integrate ehcache with the Spring Framework.

Ashley Walton