[Opensymphony-oscache] How to implement write-thru caching with oscache?

pvcache <[email protected]> Sat, 30 Jul 2005 21:16:28 CDT
Newsgroups gmane.comp.java.open-symphony.os-cache
Message-ID <31705789.1122776218555.JavaMail.os-j2ee@opensymphony01.contegix.com>
Hi, I am trying to implement the caching with oscache but its not giving any results,
the table is displayed properly but I am hitting the bean and issuing the query every
time instead of using the cache, I have kept everything in application scope and not
using any sessions, I just hit the jsp directly and it shows me the table:

This is my jsp code where I dump out the table,  very barebones:

<TABLE BORDER=2>
<caption>Table Output</caption>
<cache:cache key="key1" group="group1" time="-1" scope="application">
<jsp:useBean id="display" class="reports.TableClass" scope="application"/>
<jsp:getProperty name="display" property="result" />
</cache:cache>
</TABLE>

This is the "bean" which returns table data, this is very barebones too,
I make the thread in showTable sleep for 4 secs to simulate a big query,
so my jsp displays the table after 4 secs, I want it to use the cache and
show the output right away instead of hitting showTable every time:

public class TableClass1 {
	
	private ArrayList result;

	public TableClass1() { }

	public ArrayList getResult() {
	  showTable();
	  return result;
	}

	public void showTable() {
	  Thread.sleep(4000);
	  result = new ArrayList();
          //do a lot of JDBC stuff
          //which populates "result"
        }
}

I would appreciate any help on why this is not working, should I use try
to use the oscache api directly instead of wrapping within a cache tag?

Thank you.

---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=4658&messageID=11764#11764