Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Caching in application scope JSF managed bean

 
Mohammed Amine Tazi
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18164
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mohammed Amine Tazi
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks and have a nice day
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic