[Opensymphony-oscache] how to use OScache grouping without TagLibs ??
Rajeev <[email protected]>
| Newsgroups | gmane.comp.java.open-symphony.os-cache |
|---|---|
| Message-ID | <3968502.1110879729769.JavaMail.os-j2ee@opensymphony01.contegix.com> |
1. Put the oscache.jar file in the /WEB-INF/lib directory
2. Put the oscache.properties file in the /WEB-INF/classes directory and edit the properties contained within it (for example if you want disk caching, configure the persistence listener and edit the cache.path property to point to where you want the cache files stored on disk).
3. D:\travelCache\cache is the folder where everything will be cached.
4. Your directory structure should now look something like this:
$WEB_APPLICATION\WEB-INF\lib\oscache.jar
$WEB_APPLICATION\WEB-INF\classes\oscache.properties
use the following method
GeneralCacheAdministrator.putInCache(key,content,groups);
code in the java file where you want to cache object
// Fetch the Object[] from Cache if it exists
String cacheKey = "SideNav"+object_id;
Object[] temp = null ;
if(GeneralCacheAdministrator.getFromCache(cacheKey)!= null){
temp = (Object[]) GeneralCacheAdministrator.getFromCache(cacheKey);
if(temp != null)return temp;
}
// A cache doesn't exist for this key. Get the output from database.
// to cache the object array
String groups[] = new String[1];
groups[0]="SideNavlisting";
if(obj != null) GeneralCacheAdministrator.putInCache(cacheKey,obj,groups);
//
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=677&messageID=2616#2616