org.springframework.cache.ehcache.EhCacheCache Java Examples
The following examples show how to use
org.springframework.cache.ehcache.EhCacheCache.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InstrumentedEhCacheCacheManager.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Override protected Collection<Cache> loadCaches() { Assert.notNull(this.cacheManager, "A backing EhCache CacheManager is required"); Status status = this.cacheManager.getStatus(); Assert.isTrue(Status.STATUS_ALIVE.equals(status), "An 'alive' EhCache CacheManager is required - current cache is " + status.toString()); String[] names = this.cacheManager.getCacheNames(); Collection<Cache> caches = Sets.newLinkedHashSetWithExpectedSize(names.length); for (String name : names) { if (enableMetrics) { caches.add(new InstrumentedEhCacheCache(this.cacheManager.getEhcache(name))); } else { caches.add(new EhCacheCache(this.cacheManager.getEhcache(name))); } } return caches; }
Example #2
Source File: AutoCreatingEhCacheCacheManager.java From find with MIT License | 6 votes |
@Override protected Cache getMissingCache(final String name) { final Cache missingCache = super.getMissingCache(name); if (missingCache == null) { final CacheConfiguration cacheConfiguration = defaults.clone().name(name); final String cacheName = getCacheName(name); if (cacheExpires.containsKey(cacheName)) { cacheConfiguration.setTimeToLiveSeconds(cacheExpires.get(cacheName)); } final net.sf.ehcache.Cache ehcache = new net.sf.ehcache.Cache(cacheConfiguration); ehcache.initialise(); return new EhCacheCache(ehcache); } else { return missingCache; } }
Example #3
Source File: InstrumentedEhCacheCacheManager.java From kylin with Apache License 2.0 | 6 votes |
@Override protected Collection<Cache> loadCaches() { Assert.notNull(this.cacheManager, "A backing EhCache CacheManager is required"); Status status = this.cacheManager.getStatus(); Assert.isTrue(Status.STATUS_ALIVE.equals(status), "An 'alive' EhCache CacheManager is required - current cache is " + status.toString()); String[] names = this.cacheManager.getCacheNames(); Collection<Cache> caches = Sets.newLinkedHashSetWithExpectedSize(names.length); for (String name : names) { if (enableMetrics) { caches.add(new InstrumentedEhCacheCache(this.cacheManager.getEhcache(name))); } else { caches.add(new EhCacheCache(this.cacheManager.getEhcache(name))); } } return caches; }
Example #4
Source File: RemoteLocalFailOverCacheManagerTest.java From kylin with Apache License 2.0 | 6 votes |
@Test public void testCacheManager() { cacheManager.disableRemoteCacheManager(); Assert.assertTrue("Memcached failover to ehcache", cacheManager.getCache(QUERY_CACHE) instanceof EhCacheCache); cacheManager.enableRemoteCacheManager(); Assert.assertTrue("Memcached enabled", cacheManager.getCache(QUERY_CACHE) instanceof MemcachedCacheManager.MemCachedCacheAdaptor); // // MemcachedCacheManager remoteCacheManager = cacheManager.getRemoteCacheManager(); // for (int i = 0; i < 1000; i++) { // MemcachedClientIF client = (MemcachedClientIF) remoteCacheManager.getCache(QUERY_CACHE).getNativeCache(); // System.out.println(i + " available servers: " + client.getAvailableServers() + "; unavailable servers: " // + client.getUnavailableServers()); // try { // client.get("key"); // Thread.sleep(2000L); // } catch (Exception e) { // } // } }
Example #5
Source File: RemoteLocalFailOverCacheManagerTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Test public void testCacheManager() { cacheManager.disableRemoteCacheManager(); Assert.assertTrue("Memcached failover to ehcache", cacheManager.getCache(QUERY_CACHE) instanceof EhCacheCache); cacheManager.enableRemoteCacheManager(); Assert.assertTrue("Memcached enabled", cacheManager.getCache(QUERY_CACHE) instanceof MemcachedCacheManager.MemCachedCacheAdaptor); }