aspose file tools*
The moose likes JSF and the fly likes Caching in application scope JSF managed bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Caching in application scope JSF managed bean" Watch "Caching in application scope JSF managed bean" New topic
Author

Caching in application scope JSF managed bean

Mohammed Amine Tazi
Greenhorn

Joined: Feb 09, 2009
Posts: 22
Hi. I want to know if it's a good thing to cache Data in a JSF managed bean that has Application Scope?


PS: Knowing that Data isn't updated frequently and not very big.


SCJP 5 / SCWCD 5 / SCBCD 5 / SCDJWS 4 / SCDJWS 5 / SCEA 5
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
That solely depends on what the scope of the data is. If it is application scoped data, then you need it to put in an application scoped bean in any way.
Mohammed Amine Tazi
Greenhorn

Joined: Feb 09, 2009
Posts: 22
Thanks.
In fact, I'm wondering if it's a best practice to load a catalog of products in an application scope JSF managed bean from startup, or to use caching after the first call of a product.
And is it possible to update cache using setter methods in the managed bean.

Thanks in advance.

Amine.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16308
    
  22

There's nothing wrong with using caching in either application or session scope for a performance boost (providing you have the spare memory!). In point of fact, I have a number of apps that get menu definitions from a database at app startup, cache them, and use the cache to render menus. In most cases, these menus are static, although it's fairly simple to add a cache update command to the app.

I've used this strategy both in JSF and in Struts for years.

One thing to bear in mind, however, is that if you're using an ORM, the ORM framework is probably maintaining its own cache. So depending on circumstances, you might not see the big speed boost you're hoping for, and in fact could potentially see a small slowdown from the overhead of caching data that's in the ORM cache, so plan accordingly.


Customer surveys are for companies who didn't pay proper attention to begin with.
Mohammed Amine Tazi
Greenhorn

Joined: Feb 09, 2009
Posts: 22
Thanks and have a nice day
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Caching in application scope JSF managed bean