Examples of ICacheElement


Examples of org.apache.jcs.engine.behavior.ICacheElement

        if ( !isAlive )
        {
            return null;
        }

        ICacheElement element = null;

        try
        {
            element = ( CacheElement )
                database.read( new JISPKey( key ), index1 );
        }
        catch ( Exception e )
        {
            log.error( e );
        }

        if ( element == null )
        {
            return null;
        }

        if ( log.isDebugEnabled() )
        {
            log.debug( " " + key + ", val = " + element.getVal() );
        }

        return element;
    }
View Full Code Here

Examples of org.apache.jcs.engine.behavior.ICacheElement

     * sort of timeout.
     */
    public ICacheElement sendAndReceive( LateralElementDescriptor led )
        throws IOException
    {
        ICacheElement ice = null;

        if ( led == null )
        {
            return null;
        }
View Full Code Here

Examples of org.apache.jcs.engine.behavior.ICacheElement

     * @exception IOException
     */
    public ICacheElement sendAndReceive( LateralElementDescriptor led )
        throws IOException
    {
        ICacheElement ice = null;

        log.debug( "sendAndReceive led" );

        if ( led == null )
        {
View Full Code Here

Examples of org.apache.jcs.engine.behavior.ICacheElement

        {
            Object[] keys = cache.getKeyArray();
            int size = keys.length;

            Serializable key;
            ICacheElement cacheElement;
            IElementAttributes attributes;

            for ( int i = 0; i < size; i++ )
            {
                key = ( Serializable ) keys[ i ];
                cacheElement = cache.getQuiet( key );

                if ( cacheElement == null )
                {
                    continue;
                }

                attributes = cacheElement.getElementAttributes();

                boolean remove = false;

                long now = System.currentTimeMillis();

                // Useful, but overkill even for DEBUG since it is written for
                // every element in memory
                //
                // if ( log.isDebugEnabled() )
                // {
                //     log.debug( "IsEternal: " + attributes.getIsEternal() );
                //     log.debug( "MaxLifeSeconds: "
                //                + attributes.getMaxLifeSeconds() );
                //     log.debug( "CreateTime:" + attributes.getCreateTime() );
                // }

                // If the element is not eternal, check if it should be
                // removed and remove it if so.

                if ( !cacheElement.getElementAttributes().getIsEternal() )
                {
                    remove = checkForRemoval( cacheElement, now );

                    if ( remove )
                    {
                        cache.remove( cacheElement.getKey() );
                    }
                }

                // If the item is not removed, check is it has been idle
                // long enough to be spooled.

                if ( !remove && ( maxMemoryIdleTime != -1 ) )
                {
                    final long lastAccessTime = attributes.getLastAccessTime();

                    if ( lastAccessTime + maxMemoryIdleTime < now )
                    {
                        if ( log.isDebugEnabled() )
                        {
                            log.debug( "Exceeded memory idle time: "
                                       + cacheElement.getKey() );
                        }

                        // FIXME: Shouldn't we ensure that the element is
                        //        spooled before removing it from memory?

                        cache.remove( cacheElement.getKey() );

                        cache.waterfal( cacheElement );
                    }
                }
View Full Code Here

Examples of org.apache.jcs.engine.behavior.ICacheElement

        if ( log.isDebugEnabled() )
        {
            log.debug( "Trying to get from disk: " + key );
        }

        ICacheElement object = null;

        try
        {
            storageLock.readLock();
View Full Code Here

Examples of org.apache.jcs.engine.behavior.ICacheElement

     *@exception  IOException
     */
    public ICacheElement getQuiet( Serializable key )
        throws IOException
    {
        ICacheElement ce = null;

        MemoryElementDescriptor me = (MemoryElementDescriptor) map.get(key);
        if ( me != null )
        {
            if ( log.isDebugEnabled() )
View Full Code Here

Examples of org.apache.jcs.engine.behavior.ICacheElement

     *@exception  IOException
     */
    public ICacheElement get( Serializable key )
        throws IOException
    {
        ICacheElement ce = null;

        if ( log.isDebugEnabled() )
        {
            log.debug( "getting item for key: " + key );
        }
       
        MemoryElementDescriptor me = (MemoryElementDescriptor) map.get(key);

        if ( me != null )
        {
            if ( log.isDebugEnabled() )
            {
                log.debug( cacheName + ": LRUMemoryCache hit for " + key );
            }
           
            ce = me.ce;
           
            ce.getElementAttributes().setLastAccessTimeNow();
            makeFirst( me );
        }
        else
        {
            log.debug( cacheName + ": LRUMemoryCache miss for " + key );
View Full Code Here

Examples of org.apache.jcs.engine.behavior.ICacheElement

                for ( int i = 0; i < chunkSizeCorrected; i++ )
                {
                    // Might want to rename this "overflow" incase the hub
                    // wants to do something else.
                    Serializable last = ( Serializable ) mrulist.getLast();
                    ICacheElement ceL = ( ICacheElement ) map.get( last );
                    cache.spoolToDisk( ceL );

                    // need a more fine grained locking here
                    synchronized ( map )
                    {
View Full Code Here

Examples of org.apache.jcs.engine.behavior.ICacheElement

     * @exception IOException
     */
    public ICacheElement getQuiet( Serializable key )
        throws IOException
    {
        ICacheElement ce = null;

        try
        {

          ce = ( ICacheElement ) map.get( key );
View Full Code Here

Examples of org.apache.jcs.engine.behavior.ICacheElement

     * @exception IOException
     */
    public ICacheElement get( Serializable key )
        throws IOException
    {
        ICacheElement ce = null;
        boolean found = false;

        try
        {

            if ( log.isDebugEnabled() )
            {
                log.debug( "get> key=" + key );
                log.debug( "get> key=" + key.toString() );
            }

            ce = ( ICacheElement ) map.get( key );
            if ( log.isDebugEnabled() )
            {
                log.debug( "ce =" + ce );
            }

            if ( ce == null )
            {

            }
            else
            {
                found = true;
                ce.getElementAttributes().setLastAccessTimeNow();
                //ramHit++;
                if ( log.isDebugEnabled() )
                {
                    log.debug( cacheName + " -- RAM-HIT for " + key );
                }
            }

        }
        catch ( Exception e )
        {
            log.error( e );
        }

        try
        {

            if ( !found )
            {
                // Item not found in all caches.
                //miss++;
                if ( log.isDebugEnabled() )
                {
                    log.debug( cacheName + " -- MISS for " + key );
                }
                return null;
                //throw new ObjectNotFoundException( key + " not found in cache" );
            }
        }
        catch ( Exception e )
        {
            log.error( "Error handling miss", e );
            return null;
        }

        try
        {
            synchronized ( lockMe )
            {
                mrulist.remove( ce.getKey() );
                mrulist.addFirst( ce.getKey() );
            }
        }
        catch ( Exception e )
        {
            log.error( "Error making first", e );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.