satheesh created JCS-97:
---------------------------

             Summary: Unable to get the stored Cached object from JCS
                 Key: JCS-97
                 URL: https://issues.apache.org/jira/browse/JCS-97
             Project: Commons JCS
          Issue Type: Bug
          Components: Composite Cache
    Affects Versions: jcs-1.3
         Environment: Production bug
            Reporter: satheesh
             Fix For: jcs-1.3


when ever i am storing more than 1000 objects using "presessioncache" (cache 
name)



whenever i am trying  to get the objects from stored memory it always returns 
null. please see my code below  and cache.ccf file.if i want to add 10000 
objects could you tell me the configuration of cache.ccf file

cache.ccf file
***************************************************************************************************************************
# DEFAULT CACHE REGION

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

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

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

# 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=c:/genone/wap/session
jcs.auxiliary.DC.attributes.MaxPurgatorySize=10000
jcs.auxiliary.DC.attributes.MaxKeySize=10000
jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=300000
jcs.auxiliary.DC.attributes.MaxRecycleBinSize=7500
jcs.auxiliary.DC.attributes.OptimizeOnShutdown=true

# Primary Disk Cache -- faster than the rest because of memory key storage
jcs.auxiliary.preSessionDC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.preSessionDC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.preSessionDC.attributes.DiskPath=c:/genone/wap/preSessionCache
jcs.auxiliary.preSessionDC.attributes.MaxPurgatorySize=80000
jcs.auxiliary.preSessionDC.attributes.MaxKeySize=60000
jcs.auxiliary.preSessionDC.attributes.OptimizeAtRemoveCount=300000
jcs.auxiliary.preSessionDC.attributes.MaxRecycleBinSize=7500
jcs.auxiliary.preSessionDC.attributes.OptimizeOnShutdown=true

# Primary Disk Cache -- faster than the rest because of memory key storage
jcs.auxiliary.postSessionDC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.postSessionDC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.postSessionDC.attributes.DiskPath=c:/genone/wap/postSessionCache
jcs.auxiliary.postSessionDC.attributes.MaxPurgatorySize=80000
jcs.auxiliary.postSessionDC.attributes.MaxKeySize=80000
jcs.auxiliary.postSessionDC.attributes.OptimizeAtRemoveCount=300000
jcs.auxiliary.postSessionDC.attributes.MaxRecycleBinSize=7500
jcs.auxiliary.postSessionDC.attributes.OptimizeOnShutdown=true


import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.jcs.JCS;
import org.apache.log4j.Logger;

*************************************************************************************************************************
public class PreSessionManager {
  

    private static PreSessionManager instance;

    private JCS preSessionCache;
    private JCS patientSessionCache;

  
    public PreSessionManager() {
        log4j.info("Entering Constructor.");
        try {
            preSessionCache = JCS.getInstance("preSessionCache");
            patientSessionCache = JCS.getInstance("patientSessionCache");
        } catch (Exception e) {
            log4j.error("PreSession Error:", e);
        }
        log4j.info("Exiting Constructor.");
    }

    /**
     *
     * @return .
     */
    public static PreSessionManager getInstance() {
        log4j.info("Entering getInstance.");
        synchronized (PreSessionManager.class) {
            if (instance == null) {
                instance = new PreSessionManager();
            }
        }
        log4j.info("Exiting getInstance.");
        return instance;
    }

    /**
     *
     * @param id .
     * @return .
     */
    public PreSessionBean getPreSessionBean(final String id) {
        log4j.info("Inside getPreSessionBean.");
        return (PreSessionBean) preSessionCache.get(id);
    }
    
    public PreSessionBean getPatientSessionBean(final String id) {
        log4j.info("Inside getPatientSessionBean.");
        return (PreSessionBean) patientSessionCache.get(id);
    }

    /**
     *
     * @param bean .
     * @return .
     */
    public synchronized String createPreSession(final PreSessionBean bean) {
        log4j.info("Entering createPreSession");
        try {
            SimpleDateFormat sdf = new SimpleDateFormat(
                    "ddMMMyyyy(HH)mm:ss,SSS");           
            
            Date date = new Date();
            String szTempSession = sdf.format(date);
            szTempSession = szTempSession.replace("(", "h");
            szTempSession = szTempSession.replace(")", "m");
            szTempSession = szTempSession.replace(":", "s");
            szTempSession = szTempSession.replace(",", "n");
            log4j.info(" PatientID"+bean.getSzPatientID());
            preSessionCache.put(szTempSession, bean);
            patientSessionCache.put(szTempSession, bean);
            log4j.info("Exiting createPreSession");
            return szTempSession;
        } catch (Exception e) {
            log4j.error("PreSession Error:", e);
            log4j.info("Exiting createPreSession");
            return null;
        }
    }

    /**
     *
     * @param szPatientID .
     * @param szGuidelineIDs .
     * @param isWAPSL .
     * @return .
     */
    public String createPreSession(final String szPatientID,
            final String szGuidelineIDs, final boolean isWAPSL) {
        log4j.info("Entering createPreSession");
        PreSessionBean bean = new PreSessionBean();
        bean.setSzGuidelineID(szGuidelineIDs);
        bean.setSzPatientID(szPatientID);
        bean.setWAPSL(isWAPSL);
        log4j.info("Exiting createPreSession");
        return createPreSession(bean);
    }

    /**
     *
     * @param id .
     * @return .
     */
    public PreSessionBean removePreSession(final String id) {
        log4j.info("Entering removePreSession");
        try {
            PreSessionBean bean = (PreSessionBean) preSessionCache.get(id);
            preSessionCache.remove(id);
            log4j.info("Exiting removePreSession");
            return bean;
        } catch (Exception e) {
            log4j.error("PreSession Error:", e);
            log4j.info("Exiting removePreSession");
            return null;
        }
    }
}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to