Package net.sf.ehcache

Examples of net.sf.ehcache.Ehcache


            fail("Should have thrown IllegalArgumentException");
        } catch (IllegalArgumentException expected) {
            assertTrue(true);
        }

        Ehcache myCache = cacheManager.getCache("castickets");
        cache.setCache(myCache);
        assertEquals(myCache, cache.getCache());
    }
View Full Code Here


    public EHCacheReplayCache(String key, CacheManager cacheManager) {
        this.cacheManager = cacheManager;
       
        CacheConfiguration cc = EHCacheManagerHolder.getCacheConfiguration(key, cacheManager);

        Ehcache newCache = new Cache(cc);
        cache = cacheManager.addCacheIfAbsent(newCache);

        // Set the TimeToLive value from the CacheConfiguration
        ttl = cc.getTimeToLiveSeconds();
    }
View Full Code Here

        return new EhcacheTimestampsRegion( accessStrategyFactory, getCache( regionName ), properties );
    }

    private Ehcache getCache(String name) throws CacheException {
        try {
            Ehcache cache = manager.getEhcache( name );
            if ( cache == null ) {
                LOG.unableToFindEhCacheConfiguration( name );
                manager.addCache( name );
                cache = manager.getEhcache( name );
                LOG.debug( "started EHCache region: " + name );
View Full Code Here

            cacheManager = EHCacheUtil.createCacheManager(conf);
        }
       
        CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(CACHE_KEY, cacheManager);
       
        Ehcache newCache = new Cache(cc);
        cache = cacheManager.addCacheIfAbsent(newCache);
    }
View Full Code Here

        // Cannot overflow to disk as SecurityToken Elements can't be serialized
        @SuppressWarnings("deprecation")
        CacheConfiguration cc = EHCacheManagerHolder.getCacheConfiguration(key, cacheManager)
            .overflowToDisk(false); //tokens not writable
       
        Ehcache newCache = new Cache(cc);
        cache = cacheManager.addCacheIfAbsent(newCache);
       
        // Set the TimeToLive value from the CacheConfiguration
        ttl = cc.getTimeToLiveSeconds();
    }
View Full Code Here

    }
    return cacheManager;
  }
 
  protected Ehcache getCache() {
     Ehcache cache = getCacheManager().getEhcache(cacheName);
         if (cache == null) {
             throw new CacheException("cache '" + cacheName
                     + "' not found in configuration");
         }
         if (!(cache instanceof BlockingCache)) {
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

        if (this.logger.isDebugEnabled()) {
            this.logger.debug("Found " + cacheNames.length + " caches to clean.");
        }
       
        for (final String cacheName : cacheNames) {
            final Ehcache cache = this.cacheManager.getEhcache(cacheName);
           
            final long preEvictSize = cache.getMemoryStoreSize();
            final long startEviction = System.currentTimeMillis();
            cache.evictExpiredElements();
           
            if (this.logger.isDebugEnabled()) {
                final long evicted = preEvictSize - cache.getMemoryStoreSize();
                evictions += evicted;
                this.logger.debug("Evicted " + evicted + " expired elements from cache '" + cacheName + "' in " + (System.currentTimeMillis() - startEviction) + "ms");
            }
        }
       
View Full Code Here

    /* (non-Javadoc)
     * @see org.hibernate.cache.CacheProvider#buildCache(java.lang.String, java.util.Properties)
     */
    public Cache buildCache(String regionName, Properties properties) throws CacheException {
        try {
            Ehcache cache = this.cacheManager.getEhcache(regionName);

            if (cache == null) {
                this.logger.warn("Could not find a specific ehcache configuration for cache regionNamed '" + regionName + "'. The default cache will be used.");
                this.cacheManager.addCache(regionName);
                cache = this.cacheManager.getEhcache(regionName);
View Full Code Here

        if (key == null) {
            return null;
        }

        String cacheName = cacheName(key, metadata.getCacheGroups());
        Ehcache cache = cacheManager.getCache(cacheName);

        if (cache == null) {
            return null;
        }

        Element result = cache.get(key);
        return result != null ? (List) result.getObjectValue() : null;
    }
View Full Code Here

TOP

Related Classes of net.sf.ehcache.Ehcache

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.