Package org.apache.jcs.engine.behavior

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


                        while ( itr.hasNext() )
                        {
                            Map.Entry entry = (Map.Entry) itr.next();

                            ICacheElement ce = (ICacheElement) entry.getValue();

                            aux.update( ce );
                        }
                    }
                }
View Full Code Here


        IElementSerializer elementSerializer = new StandardSerializer();

        IElementAttributes attr = new ElementAttributes();
        attr.setMaxLifeSeconds( 34 );

        ICacheElement before = new CacheElement( cacheName, key, value );
        before.setElementAttributes( attr );

        ICacheElementSerialized serialized = SerializationConversionUtil.getSerializedCacheElement( before,
                                                                                                    elementSerializer );
        assertNotNull( "Should have a serialized object.", serialized );
        System.out.println( "testSimpleConversion, " + serialized );

        ICacheElement after = SerializationConversionUtil.getDeSerializedCacheElement( serialized, elementSerializer );

        assertNotNull( "Should have a deserialized object.", after );
        assertEquals( "Values should be the same.", before.getVal(), after.getVal() );
        assertEquals( "Attributes should be the same.", before.getElementAttributes().getMaxLifeSeconds(), after
            .getElementAttributes().getMaxLifeSeconds() );
        assertEquals( "Keys should be the same.", before.getKey(), after.getKey() );
        assertEquals( "Cache name should be the same.", before.getCacheName(), after.getCacheName() );

    }
View Full Code Here

        IElementSerializer elementSerializer = null;// new StandardSerializer();

        IElementAttributes attr = new ElementAttributes();
        attr.setMaxLifeSeconds( 34 );

        ICacheElement before = new CacheElement( cacheName, key, value );
        before.setElementAttributes( attr );

        try
        {
            SerializationConversionUtil.getSerializedCacheElement( before, elementSerializer );
            fail( "We should have received an IOException." );
View Full Code Here

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

        ICacheElement object = null;
        try
        {
            storageLock.readLock().acquire();
            try
            {
View Full Code Here

            keys = cache.getMemoryCache().getKeyArray();
        }

        LinkedList records = new LinkedList();

        ICacheElement element;
        IElementAttributes attributes;
        CacheElementInfo elementInfo;

        DateFormat format = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT );

        long now = System.currentTimeMillis();

        for ( int i = 0; i < keys.length; i++ )
        {
            element = cache.getMemoryCache().getQuiet( (Serializable) keys[i] );

            attributes = element.getElementAttributes();

            elementInfo = new CacheElementInfo();

            elementInfo.key = String.valueOf( keys[i] );
            elementInfo.eternal = attributes.getIsEternal();
View Full Code Here

        // stop at the first non serializable exception.
        try
        {
            while ( iter.hasNext() )
            {
                ICacheElement ce = (ICacheElement) ( (Map.Entry) iter.next() ).getValue();

                out.writeObject( ce.getVal() );
            }
        }
        catch ( Exception e )
        {
            log.info( "Problem getting byte count.  Likley cause is a non serilizable object." + e.getMessage() );
View Full Code Here

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

        ICacheElement object = null;
        try
        {
            storageLock.readLock().acquire();
            try
            {
View Full Code Here

     * @throws IOException
     */
    private ICacheElement readElement( Serializable key )
        throws IOException
    {
        ICacheElement object = null;

        IndexedDiskElementDescriptor ded = (IndexedDiskElementDescriptor) keyHash.get( key );

        if ( ded != null )
        {
View Full Code Here

        // DO WORK
        int numToInsert = 10;
        for ( int i = 0; i < numToInsert; i++ )
        {
            ICacheElement element = new CacheElement( cacheName, String.valueOf( i ), new Integer( i ) );
            cache.update( element, false );
        }

        cache.dispose();
View Full Code Here

        // DO WORK
        int numToInsert = 10;
        for ( int i = 0; i < numToInsert; i++ )
        {
            ICacheElement element = new CacheElement( cacheName, String.valueOf( i ), new Integer( i ) );
            cache.update( element, false );
        }

        cache.dispose();
View Full Code Here

TOP

Related Classes of org.apache.jcs.engine.behavior.ICacheElement

Copyright © 2018 www.massapicom. 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.