Package org.apache.jcs.engine

Examples of org.apache.jcs.engine.CacheElement


            while ( notDone )
            {
                System.out.println( "enter mesage:" );
                message = br.readLine();
                CacheElement ce = new CacheElement( "test", "test", message );
                LateralElementDescriptor led = new LateralElementDescriptor( ce );
                sender.send( led );
            }
        }
        catch ( Exception e )
View Full Code Here


     * Looks for the item in the lists.
     */
    public ICacheElement get( Serializable key )
        throws IOException
    {
        CacheElement ce = new CacheElement( cacheName, key, null );

        ICacheElement ice = null;
        try
        {
            ice = ARC( ce, true );
View Full Code Here

    /** Description of the Method */
    public void remove( String cacheName, Serializable key, long requesterId )
        throws IOException
    {
        CacheElement ce = new CacheElement( cacheName, key, null );
        LateralElementDescriptor led = new LateralElementDescriptor( ce );
        led.requesterId = requesterId;
        led.command = led.REMOVE;
        send( led );
    }
View Full Code Here

    /** Description of the Method */
    public void removeAll( String cacheName, long requesterId )
        throws IOException
    {
        CacheElement ce = new CacheElement( cacheName, "ALL", null );
        LateralElementDescriptor led = new LateralElementDescriptor( ce );
        led.requesterId = requesterId;
        led.command = led.REMOVEALL;
        send( led );
    }
View Full Code Here

        int numMes = 10;
        for ( int i = 0; i < numMes; i++ )
        {
            String message = "adsfasasfasfasdasf";
            CacheElement ce = new CacheElement( "test", "test", message );
            LateralElementDescriptor led = new LateralElementDescriptor( ce );
            led.command = LateralElementDescriptor.UPDATE;
            led.requesterId = 1;
            lur.send( led );
        }
View Full Code Here

            while ( notDone )
            {
                System.out.println( "enter mesage:" );
                message = br.readLine();
                CacheElement ce = new CacheElement( "test", "test", message );
                LateralElementDescriptor led = new LateralElementDescriptor( ce );
                lur.send( led );
            }
        }
        catch ( Exception e )
View Full Code Here

        service.setListenerId( 123456 );

        int cnt = 100;
        for ( int i = 0; i < cnt; i++ )
        {
            ICacheElement element = new CacheElement( "test", "key" + i, "value1" );
            service.update( element );
        }

        SleepUtil.sleepAtLeast( 1000 );
View Full Code Here

        lattr2.setTcpServer( "localhost:1103" );

        LateralTCPService service = new LateralTCPService( lattr2 );
        service.setListenerId( 123456 );

        ICacheElement element = new CacheElement( "test", "key", "value1" );
        service.update( element );

        SleepUtil.sleepAtLeast( 300 );

        ICacheElement element2 = new CacheElement( "test", "key", "value2" );
        service.update( element2 );

        SleepUtil.sleepAtLeast1000 );

        ICacheElement cacheElement = cacheMgr.getCache().get( "key" );
        System.out.println( "cacheElement = " + cacheElement );
        assertEquals( "Didn't get the correct object", element2.getVal(), cacheElement.getVal() );
    }
View Full Code Here

        LateralTCPService service = new LateralTCPService( lattr2 );
        service.setListenerId( 123456 );

        String key = "key";
        ICacheElement element = new CacheElement( "test", key, "value1" );
        service.update( element );

        SleepUtil.sleepAtLeast( 300 );

        ICacheElement element2 = new CacheElement( "test", key, "value2" );
        service.update( element2 );

        SleepUtil.sleepAtLeast( 1000 );

        ICacheElement cacheElement = cacheMgr.getCache().get( "key" );
        System.out.println( "cacheElement = " + cacheElement );
        assertEquals( "Didn't get the correct object", element2.getVal(), cacheElement.getVal() );
    }
View Full Code Here

        // give it our mock cache manager
        //LateralTCPListener listener = (LateralTCPListener)
        LateralTCPListener.getInstance( lattr, cacheMgr );

        // add the item to the listeners cache
        ICacheElement element = new CacheElement( "test", "key", "value1" );
        cacheMgr.getCache().update( element );

        // setup a service to talk to the listener started above.
        TCPLateralCacheAttributes lattr2 = new TCPLateralCacheAttributes();
        lattr2.setTcpListenerPort( 1108 );
        lattr2.setTcpServer( "localhost:1107" );

        LateralTCPService service = new LateralTCPService( lattr2 );
        service.setListenerId( 123456 );

        SleepUtil.sleepAtLeast300 );

        // DO WORK
        ICacheElement result = service.get( "test", "key" );

        System.out.println( "testSendAndReceived, result = " + result );
        assertNotNull( "Result should not be null.", result );
        assertEquals( "Didn't get the correct object", element.getVal(), result.getVal() );
    }
View Full Code Here

TOP

Related Classes of org.apache.jcs.engine.CacheElement

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.