1. place it in build path
2. place oscache.properties in src dir so that on building, it directly goes in classes dir
Although I am not sure how to use it. I dint use it
3. Create a class to cache the data. The class should have a init method that runs when jboss starts.
4. cache all data that u want to cache in this method
5. sample code here:
make a class object--
GeneralCacheAdministrator admin=null; ... ... .. in the method write: init(){ .. admin.putInCache(cacheName,object); .. } Now create a get method to retrieve or access this mem cached data where ever u want get(String myKey){ .. int myRefreshPeriod=180; try { // Get from the cache String key=myKey; Object data=(Object)admin.getFromCache(key,myRefreshPeriod); System.out.println("=============== from cache 1================"); } // end try catch(NeedsRefreshException nre) { try { // Get the value (probably by calling an EJB) data = xyzMethodGetFromDataBase(); // Store in the cache addToCache(myKey,dashboardData); System.out.println("=============== direct db ================"); } // end try catch(Exception exp) { // We have the current content if we want fail-over. data=(Object)nre.getCacheContent(); // It is essential that cancelUpdate is called if the // cached content is not rebuilt admin.cancelUpdate(myKey); System.out.println("=============== old cache ================"); } // end catch } // end catch |