You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-users@jakarta.apache.org by Prasad xyz <pv...@gmail.com> on 2005/07/25 04:08:26 UTC

How to implement write-thru caching with JCS?

Hi folks,

I have a simple jsp which displays a really huge table (10k+ rows),
the jsp just invokes a bean which does all the query execution and
populates & returns an arraylist based on the resultset object:

//this is within jsp1
<jsp:useBean id="display" class="reports.Database" />

<%
//this method executes the query and 
populates & returns an arraylist object
ArrayList result = display.showTable();
%>

//loop thru the arraylist to render the table

<TABLE BORDER=2>
<%
for(int i=0; i<result.size(); i++) {
	out.println(((StringBuffer)result.get(i)).toString());
}
%>
</TABLE>

I am planning to use JCS to cache the arraylist object so that I avoid
issuing a fresh query everytime a user hits jsp1.

I also have another jsp which writes to the same table, so the underlying
table is modified every time a user inputs data using the other jsp (jsp2)

My question is - how would I do write-thru caching in this scenario?
if a user hits jsp1 and the arraylist object is cached, then user goes
to jsp2 and updates some data, I want the cache to realise that the
underlying table got modified and dynamically refresh the cached
arraylist object by calling display.showTable(), so now when the 
user goes back to jsp1 then the updated data is instantly served 
from the cache, is it possible to do something like this in JCS?

I would appreciate any help on this, thanks in advance!

---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-users-help@jakarta.apache.org