Package net.sf.ehcache.constructs.blocking

Examples of net.sf.ehcache.constructs.blocking.BlockingCache


  }

  private void purgeCaches(Collection<Run> runs) {
    Cache lcache = cacheManager.getCache("runListCache");
    if (lcache != null) {
      BlockingCache listCache = new BlockingCache(lcache);
      if (listCache.getKeys().size() > 0) {
        Object cachekey = listCache.getKeys().get(0);
        if (cachekey != null) {
          List<Run> cachedruns = (List<Run>)listCache.get(cachekey).getValue();
          for (Run run : runs) {
            cachedruns.remove(run);
            cachedruns.add(run);
          }
          listCache.put(new Element(cachekey, cachedruns));
        }
      }
    }

    Cache rcache = cacheManager.getCache("runCache");
    if (rcache != null) {
      BlockingCache cache = new BlockingCache(rcache);
      HashCodeCacheKeyGenerator keygen = new HashCodeCacheKeyGenerator();
      for (Run run : runs) {
        Long cachekey = keygen.generateKey(run);
        cache.remove(cachekey);
        cache.put(new Element(cachekey, run));
      }
    }
  }
View Full Code Here


  public static <T extends Nameable> void updateCaches(CacheManager cacheManager, T obj, Class<T> cacheClass) {
    Cache cache = DbUtils.lookupCache(cacheManager, cacheClass, true);
    if (cache != null && cache.getKeys().size() > 0) {
      log.debug("Removing " + cacheClass.getSimpleName() + " " + obj.getId() + " from " + cache.getName());
      BlockingCache c = new BlockingCache(cache);
      c.remove(DbUtils.hashCodeCacheKeyFor(obj.getId()));
    }

    cache = DbUtils.lookupCache(cacheManager, cacheClass, false);
    if (cache != null && cache.getKeys().size() > 0) {
      log.debug("Removing " + cacheClass.getSimpleName() + " " + obj.getId() + " from " + cache.getName());
      BlockingCache c = new BlockingCache(cache);
      c.remove(DbUtils.hashCodeCacheKeyFor(obj.getId()));
    }
  }
View Full Code Here

    }
  }

  public static <T> void updateListCache(Cache cache, boolean replace, T obj, Class<T> cacheClass) {
    if (cache != null && cache.getKeys().size() > 0) {
      BlockingCache c = new BlockingCache(cache);
      Object cachekey = c.getKeys().get(0);
      List<T> e = (List<T>)c.get(cachekey).getObjectValue();
      if (e.remove(obj)) {
        if (replace) {
          e.add(obj);
        }
      }
      else {
        e.add(obj);
      }
      c.put(new Element(cachekey, e));
    }
  }
View Full Code Here

      else {
        return new SelfPopulatingCache(cache, this.cacheEntryFactory);
      }
    }
    if (this.blocking) {
      return new BlockingCache(cache);
    }
    return cache;
  }
View Full Code Here

      else {
        return new SelfPopulatingCache(cache, this.cacheEntryFactory);
      }
    }
    if (this.blocking) {
      return new BlockingCache(cache);
    }
    return cache;
  }
View Full Code Here

      } else {
        return new SelfPopulatingCache(cache, this.cacheEntryFactory);
      }
    }
    if (this.blocking) {
      return new BlockingCache(cache);
    }
    return cache;
  }
View Full Code Here

        if(!cacheManager.cacheExists(cacheName)) {
           cacheManager.addCache(cacheName);
        }

        Ehcache cache = cacheManager.getEhcache(cacheName);
        BlockingCache blockingCache = new BlockingCache(cache);
        blockingCache.setTimeoutMillis(timeout);
        return blockingCache;
    }
View Full Code Here

     *
     * @param cache
     *            a non-null {@link Ehcache}
     */
    public void setCache(Ehcache cache) {
        BlockingCache ref;

        if (!(cache instanceof BlockingCache)) {
            ref = new BlockingCache(cache);
            cache.getCacheManager().replaceCacheWithDecoratedCache(cache, new BlockingCache(cache));
        } else {
            ref = (BlockingCache) cache;
        }

        this.cache = ref;
View Full Code Here

TOP

Related Classes of net.sf.ehcache.constructs.blocking.BlockingCache

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.