Package org.apache.jcs.engine.control

Examples of org.apache.jcs.engine.control.CompositeCache


  private ICacheElement getCacheElement(int keyAndModelIndex) {
    KeyAndModel keyAndModel = getKeyAndModel(keyAndModelIndex);
    JcsCachingModel model = (JcsCachingModel) keyAndModel.model;

    String cacheName = model.getCacheName();
    CompositeCache cache = cacheManager.getCache(cacheName);
    GroupId groupId = new GroupId(cacheName, model.getGroup());
    GroupAttrName groupAttrName = new GroupAttrName(groupId, keyAndModel.key);
    return cache.get(groupAttrName);
  }
View Full Code Here


    String maxObjectsProperty = configProperties.getProperty("jcs.region."
        + cacheName + ".cacheattributes.MaxObjects");

    int expected = Integer.parseInt(maxObjectsProperty);

    CompositeCache cache = cacheManager.getCache(cacheName);
    ICompositeCacheAttributes cacheAttributes = cache.getCacheAttributes();
    int actual = cacheAttributes.getMaxObjects();

    assertEquals(expected, actual);
  }
View Full Code Here

   * @param name the name of the cache.
   * @return the cache retrieved from the cache manager.
   * @throws CacheNotFoundException if the cache does not exist.
   */
  protected CompositeCache getCache(String name) {
    CompositeCache cache = cacheManager.getCache(name);
    if (cache == null) {
      throw new CacheNotFoundException(name);
    }

    return cache;
View Full Code Here

        }

        String cacheName = cacheStruct.getCacheName();
        String[] groups = cacheStruct.getGroups();

        CompositeCache cache = getCache(cacheName);

        if (!ObjectUtils.isEmpty(groups)) {
          int groupCount = groups.length;
          for (int j = 0; j < groupCount; j++) {
            GroupId groupId = new GroupId(cacheName, groups[j]);
            cache.remove(groupId);
          }
        } else {
          cache.removeAll();
        }
      }
    } catch (Exception exception) {
      throw new CacheAccessException(exception);
    }
View Full Code Here

  protected Object onGetFromCache(Serializable key, CachingModel model)
      throws CacheException {
    JcsCachingModel cachingModel = (JcsCachingModel) model;
    String cacheName = cachingModel.getCacheName();

    CompositeCache cache = getCache(cacheName);

    Serializable newKey = getKey(key, cachingModel);
    Object cachedObject = null;

    try {
      ICacheElement cacheElement = cache.get(newKey);
      if (cacheElement != null) {
        cachedObject = cacheElement.getVal();
      }

    } catch (Exception exception) {
View Full Code Here

      throws CacheException {

    JcsCachingModel cachingModel = (JcsCachingModel) model;
    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) {
      throw new CacheAccessException(exception);
    }
  }
View Full Code Here

  protected void onRemoveFromCache(Serializable key, CachingModel model)
      throws CacheException {
    JcsCachingModel cachingModel = (JcsCachingModel) model;
    String cacheName = cachingModel.getCacheName();

    CompositeCache cache = getCache(cacheName);

    Serializable newKey = getKey(key, cachingModel);

    try {
      cache.remove(newKey);

    } catch (Exception exception) {
      throw new CacheAccessException(exception);
    }
  }
View Full Code Here

            {
                log.debug( "puts = " + puts );
            }
        }

        CompositeCache cache = cacheMgr.getCache( irca.getCacheName() );
        cache.localUpdate( cb );
    }
View Full Code Here

        }

        getCacheManager();
        // interface limitation here

        CompositeCache cache = ( CompositeCache ) cacheMgr.getCache( cacheName );
        cache.localRemove( key );
    }
View Full Code Here

        }
    }

    private LinkedList buildElementInfo( String cacheName ) throws Exception
    {
        CompositeCache cache =
            ( CompositeCache ) cacheHub.getCache( cacheName );

        Object[] keys = cache.getMemoryCache().getKeyArray();

        Arrays.sort( keys );

        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();
View Full Code Here

TOP

Related Classes of org.apache.jcs.engine.control.CompositeCache

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.