Package net.sf.ehcache

Examples of net.sf.ehcache.Cache$CacheStatus


        cacheManager = EHCacheManagerHolder.getCacheManager(bus, configFileURL);
        // Cannot overflow to disk as SecurityToken Elements can't be serialized
        CacheConfiguration cc = EHCacheManagerHolder.getCacheConfiguration(key, cacheManager)
            .overflowToDisk(false); //tokens not writable
       
        Cache newCache = new RefCountCache(cc);
        cache = cacheManager.addCacheIfAbsent(newCache);
        synchronized (cache) {
            if (cache.getStatus() != Status.STATUS_ALIVE) {
                cache = cacheManager.addCacheIfAbsent(newCache);
            }
View Full Code Here


        } else {
            cacheManager = EHCacheManagerHolder.getCacheManager(bus, getDefaultConfigFileURL());
        }
        CacheConfiguration cc = EHCacheManagerHolder.getCacheConfiguration(key, cacheManager);
       
        Ehcache newCache = new Cache(cc);
        cache = cacheManager.addCacheIfAbsent(newCache);
    }
View Full Code Here

    public void flush(String path, boolean flushSubtree) {
        if (logger.isDebugEnabled()) {
            logger.debug("Flushing dependencies for path : " + path);
        }
        Cache cache = cacheProvider.getDependenciesCache();
        Element element = cache.get(path);
        if (element != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("Flushing path : " + path);
            }
            cacheProvider.invalidate(path);
            cache.remove(element.getKey());
        }
        if (flushSubtree) {
            List keys = cache.getKeys();
            for (Object key : keys) {
                if (key.toString().startsWith(path)) {
                    cacheProvider.invalidate(key.toString());
                    cache.remove(key);
                }
            }
        }
    }
View Full Code Here

            }
        }

        // Ehcaches
        for (String cacheName : ehcacheManager.getCacheNames()) {
            Cache cache = ehcacheManager.getCache(cacheName);
            if (cache != null) {
                // flush
                cache.removeAll(!propagateInCluster);
                // reset statistics
                cache.clearStatistics();
            }
        }

        // Hiberante caches
        flushHibernateCaches();
View Full Code Here

     *            if set to true the flush is propagated to other cluster nodes
     */
    public static void flushEhcacheByName(String cacheName, boolean propagateInCluster) {
        logger.info("Flushing {}", cacheName);
        CacheManager ehcacheManager = getEhcacheManager();
        Cache cache = ehcacheManager.getCache(cacheName);
        if (cache != null) {
            // flush
            cache.removeAll(!propagateInCluster);
            // reset statistics
            cache.clearStatistics();
            logger.info("...done flushing {}", cacheName);
        } else {
            logger.warn("Cache with the name {} not found. Skip flushing.", cacheName);
        }
    }
View Full Code Here

        CacheManager ehcacheManager = getEhcacheManager();
        for (String cacheName : ehcacheManager.getCacheNames()) {
            if (!cacheName.startsWith("HTML")) {
                continue;
            }
            Cache cache = ehcacheManager.getCache(cacheName);
            if (cache != null) {
                // flush
                cache.removeAll(!propagateInCluster);
                // reset statistics
                cache.clearStatistics();
                logger.info("...done flushing {}", cacheName);
            }
        }
    }
View Full Code Here

 
  public Map<String, CacheStatistics> getAllCacheStatistics() {
      final Map<String, CacheStatistics> allCacheStatistics = new TreeMap<String, CacheStatistics>(CaseInsenstivieStringComparator.INSTANCE);
     
      for (final String cacheName : this.cacheManager.getCacheNames()) {
          final Cache cache = this.cacheManager.getCache(cacheName);
         
          if (null != cache && Status.STATUS_ALIVE.equals(cache.getStatus())) {
              final CacheConfiguration cacheConfiguration = cache.getCacheConfiguration();
              final Statistics statistics = cache.getStatistics();
             
              final CacheStatistics cacheStatistics = new CacheStatistics();
             
              cacheStatistics.hits = statistics.getCacheHits();
              cacheStatistics.misses = statistics.getCacheMisses();
View Full Code Here

   * @see Cache#getStatistics()
   * @param cacheName
   * @return the {@link Statistics} for the specified cache; returns null of cache is not alive or doesn't exist
   */
  public Statistics getCacheStatistics(String cacheName) {
    Cache cache = this.cacheManager.getCache(cacheName);
    if(null != cache && Status.STATUS_ALIVE.equals(cache.getStatus())) {
      Statistics result = cache.getStatistics();
      return result;
    }

    return null;
  }
View Full Code Here

   * @see Status#STATUS_ALIVE
   * @see Cache#getStatus()
   * @param cacheName
   */
  public void clearCache(String cacheName) {
    Cache cache = this.cacheManager.getCache(cacheName);
    if(null != cache && Status.STATUS_ALIVE.equals(cache.getStatus())) {
      cache.removeAll();
      logger.warn("finished removeAll for cache: " + cacheName);
    }
  }
View Full Code Here

        if (!ObjectUtils.isEmpty(cacheNames)) {
            CacheException cacheException = null;

            try {
                for (final String cacheName : cacheNames) {
                    final Cache cache = getCache(cacheName);
                    cache.removeAll();
                }
            }
            catch (CacheException exception) {
                cacheException = exception;
            }
View Full Code Here

TOP

Related Classes of net.sf.ehcache.Cache$CacheStatus

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.