How to retreiv

kothakotta <[email protected]>
Newsgroups gmane.comp.jakarta.cactus.devel
Message-ID <[email protected]>
how to retrieve complete list of Cached elements from JCS class

This is how I m using the JCS


import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Properties;

import org.apache.jcs.JCS;
import org.apache.jcs.access.exception.CacheException;
import org.apache.jcs.engine.control.CompositeCacheManager;
import org.springframework.beans.factory.annotation.Autowired;

import com.directv.adminserver.pojo.NflAlertPOJO;
import org.apache.log4j.Logger;

public class AlertMonitorManager {

	private static JCS cache;
	
	
	private static String cacheConfigFile;
	
	private static LinkedHashMap<String, JCS> cacheMap = new
LinkedHashMap<String, JCS>();
	
	
	

	public AlertMonitorManager(String file) {
	}
	
	
	public static JCS loadCache(String cacheName, Properties cacheConfig){				
		if(cacheName != null){
			cache = cacheMap.get(cacheName);
		} 
		if(cache == null)
		{
			
			CompositeCacheManager ccm =
CompositeCacheManager.getUnconfiguredInstance();
			Properties props = new Properties(); 
			
			ccm.configure(cacheConfig); 
			
			try {
				cache = JCS.getInstance(cacheName);
				
				System.out.println("The Cache : "+cache);
				cacheMap.put(cacheName, cache);
			} catch (CacheException e) {
				e.printStackTrace();
			}			
		}				 
		return cache;
	}

	
}



cache.ccf.properties
# DEFAULT CACHE REGION

# sets the default aux value for any non configured caches
jcs.default=DC,RFailover
jcs.default.cacheattributes= org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=1000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLifeSeconds=3600
jcs.default.elementattributes.IdleTime=1800
jcs.default.elementattributes.IsSpool=true
jcs.default.elementattributes.IsRemote=true
jcs.default.elementattributes.IsLateral=true


# CACHE REGIONS AVAILABLE

# Regions preconfigured for caching
jcs.region.nflAlert=DC,RFailover
jcs.region.nflAlert.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.nflAlert.cacheattributes.MaxObjects=1200
jcs.region.nflAlert.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.fifo.FIFOMemoryCache 
jcs.region.nflAlert.elementattributes.IsEternal=false
jcs.region.nflAlert.elementattributes.MaxLifeSeconds=7200
jcs.region.nflAlert.elementattributes.IdleTime=1800
jcs.region.nflAlert.elementattributes.IsSpool=true
jcs.region.nflAlert.elementattributes.IsRemote=true
jcs.region.nflAlert.elementattributes.IsLateral=true

# AUXILIARY CACHES AVAILABLE

# Primary Disk Cache -- faster than the rest because of memory key storage
jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.DC.attributes.DiskPath=/usr/opt/bookstore/raf
jcs.auxiliary.DC.attributes.MaxPurgatorySize=10000
jcs.auxiliary.DC.attributes.MaxKeySize=10000
jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=300000
jcs.auxiliary.DC.attributes.MaxRecycleBinSize=7500

# Remote RMI Cache set up to failover
jcs.auxiliary.RFailover=org.apache.jcs.auxiliary.remote.RemoteCacheFactory
jcs.auxiliary.RFailover.attributes=org.apache.jcs.auxiliary.remote.RemoteCacheAttributes
jcs.auxiliary.RFailover.attributes.RemoteTypeName=LOCAL
jcs.auxiliary.RFailover.attributes.FailoverServers=scriptserver:1102
jcs.auxiliary.RFailover.attributes.GetOnly=false





import java.io.InputStream;
import java.util.Properties;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.jcs.JCS;
import org.apache.jcs.access.CacheAccess;
import org.apache.jcs.engine.control.CompositeCache;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.directv.adminserver.service.AlertMonitorManager;


@Controller
@RequestMapping("alerts")
public class AlertsControllers {
	
	@RequestMapping(method = RequestMethod.GET)
	protected ModelAndView getAlerts(HttpServletRequest request,
HttpServletResponse response) throws Exception{
		
		Properties props = new Properties();
        InputStream inputStream = this.getClass().getClassLoader()
            .getResourceAsStream("cache.ccf.properties");
		
		JCS cache = AlertMonitorManager.loadCache("nflAlert", props);
		
                 cache.put("1", "Error");
                 cache.put("2", "Exception");

		(String)cache.get("1");

		
		return null;
	}

}



I am able to retrieve the Cache Element by key. But I want to retrieve the
Complete List or Map of Cache Elements which are present in the JCS cache.

Any reply for this issue is Thankfull.

-- 
View this message in context: http://old.nabble.com/How-to-retreiv-tp31374117p31374117.html
Sent from the JCS - Dev mailing list archive at Nabble.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.