Package org.apache.jcs.engine

Examples of org.apache.jcs.engine.CacheElement


    String cacheName = cachingModel.getCacheName();

    CompositeCache cache = getCache(cacheName);

    Serializable newKey = getKey(key, cachingModel);
    ICacheElement newCacheElement = new CacheElement(cache.getCacheName(),
        newKey, obj);

    IElementAttributes elementAttributes = cache.getElementAttributes().copy();
    newCacheElement.setElementAttributes(elementAttributes);

    try {
      cache.update(newCacheElement);

    } catch (Exception exception) {
View Full Code Here


      }
      if (!(actual instanceof CacheElement)) {
        return false;
      }

      CacheElement expectedElement = (CacheElement) expected;
      CacheElement actualElement = (CacheElement) actual;

      return equals(expectedElement, actualElement);
    }
View Full Code Here

    // cache manager throws exception.
    Serializable key = "Jabba";
    Object objToStore = "Bobba Fett";

    CacheElement cacheElement = new CacheElement(cachingModel.getCacheName(),
        key, objToStore);
    cache.update(cacheElement);
    cacheControl.setMatcher(new CacheElementMatcher());

    RuntimeException expected = new RuntimeException();
View Full Code Here

      GroupId groupId = new GroupId(CACHE_NAME, group);
      GroupAttrName groupAttrName = new GroupAttrName(groupId, key);
      key = groupAttrName;
    }

    ICacheElement cacheElement = new CacheElement(CACHE_NAME, key,
        cacheEntry.value);
    IElementAttributes attributes = cache.getElementAttributes().copy();
    cacheElement.setElementAttributes(attributes);

    cache.update(cacheElement);
    return key;
  }
View Full Code Here

        watch = ( ICacheObserver ) obj;

        p( "subscribing to the server" );

        watch.addCacheListener( "testCache", this );
        ICacheElement cb = new CacheElement( "testCache", "testKey", "testVal" );

        for ( int i = 0; i < count; i++ )
        {
            cb = new CacheElement( "testCache", "" + i, "" + i );

            if ( delete )
            {
                p( "deleting a cache item from the server " + i );

                cache.remove( cb.getCacheName(), cb.getKey() );
            }
            if ( write )
            {
                p( "putting a cache bean to the server " + i );

                try
                {
                    cache.update( cb );
                }
                catch ( ObjectExistsException oee )
                {
                    p( oee.toString() );
                }
            }
            if ( read )
            {
                try
                {
                    Object val = cache.get( cb.getCacheName(), cb.getKey() );
                    p( "get " + cb.getKey() + " returns " + val );
                }
                catch ( ObjectNotFoundException onfe )
                {
                }
            }
View Full Code Here

        // Add items to cache

        for ( int i = 0; i < items; i++ )
        {
            ICacheElement ice = new CacheElement(
                cache.getCacheName(), i + ":key", region + " data " + i);
            ice.setElementAttributes(cache.getElementAttributes().copy());
            lru.update(ice);
        }

        // Test that initial items have been purged
View Full Code Here

     *@exception  IOException
     */
    public IElementAttributes getElementAttributes( Serializable key )
        throws CacheException, IOException
    {
        CacheElement ce = ( CacheElement ) get( key );
        if ( ce == null )
        {
            throw new ObjectNotFoundException( "key " + key + " is not found" );
        }
        return ce.getElementAttributes();
    }
View Full Code Here

     * @exception IOException
     */
    public void remove( String cacheName, Serializable key, byte requesterId )
        throws IOException
    {
        CacheElement ce = new CacheElement( cacheName, key, null );
        LateralElementDescriptor led = new LateralElementDescriptor( ce );
        led.requesterId = requesterId;
        led.command = led.REMOVE;
        sender.send( led );
    }
View Full Code Here

     */
    public ICacheElement get( String cacheName, Serializable key )
        throws IOException
    {
        //p( "get(cacheName,key,container)" );
        CacheElement ce = new CacheElement( cacheName, key, null );
        LateralElementDescriptor led = new LateralElementDescriptor( ce );
        //led.requesterId = requesterId; // later
        led.command = led.GET;
        return sender.sendAndReceive( led );
        //return null;
View Full Code Here

     * @exception IOException
     */
    public void removeAll( String cacheName, byte requesterId )
        throws IOException
    {
        CacheElement ce = new CacheElement( cacheName, "ALL", null );
        LateralElementDescriptor led = new LateralElementDescriptor( ce );
        led.requesterId = requesterId;
        led.command = led.REMOVEALL;
        sender.send( led );
    }
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.