Jul
20
2004

Database caching in Struts apps

In a JSP, it’s easy enough to implement a caching strategy, since there’s a wealth of cool caching taglibs that will help you out. But what about Struts apps?

In a struts app, all your database logic is accessed via the action (or more typically via a DAO type pattern in the action, but you get my gist). So, how do you implement caching in the action?

I guess you could roll your own by keeping a private Date field of the last time you did a lookup (even keep that in your base action class), but it’s not that clean.

I’ve heard good things about JCache – that it can help with this sort of stuff. So I’ll be having a look over the next week or so. Anyone else have any good pointers for this type of scenario?

About the Author: Glen Smith

4 Comments + Add Comment

  • Try OSCache – http://www.opensymphony.com. I’ve used it to get 300%+ performance boosts :)

  • Hmm, if you are using Struts then caching of Data should be in the Model (data) layer and not in the action, so put it in your DAO (iBaits and Hibreanate do caching).

    .V

  • I disagree – I’d say many times you can just stick with caching parts of the view – and this is where OSCache comes in (esp. its taglibs)

  • Thanks for the suggestions guys. I guess I’m less interested in JSP cacheing, and more interested in caching the actual DAO work which happens from calls originating in the action.

    Anyways I’ve come across a great resource at Manageability which gives me heaps of food for thought.

Leave a comment

Glen Smith

About Glen

Co-author Grails in Action