I have a Page which fills on every "preRenderView" some lists with values of a DB
//preRenderView Method
public void init(){
loadChapterStructure();
loadCategoryStructure();
}
Due to the fact, that the chapters and categories don't chance really often (e.g. just one time a day), they only should be loaded once for every user (on first page load).
When the user now performs some GET-requests on the same view (to keep the page etc. bookmarkable), it would be good not to load these "static" values again.
Is there a way to achieve e.g. loading the chapters and categories e.g. only once every hour? Is there any best-practice for this issue?
Thanks for any help!
You can implement an
@ApplicationScoped
managed bean which caches the DB values. Just access the data through it instead of directly using the DAO from your view beans:Then inject the bean wherever your want using the
@ManagedProperty
annotation: