private void clearChache() throws IOException { CacheManager cacheManager = CacheManager.create(new ClassPathResource("echache.xml").getInputStream()); Cache cache1 = cacheManager.getCache("turmas-efetivas-cache"); Cache cache2 = cacheManager.getCache("turmas-pendencias-cache"); cache1.removeAll(); cache2.removeAll(); }
public void clear() throws CacheException { try { ehcache.removeAll(); } catch (IllegalStateException e) { throw new CacheException(e); } }
@Override public void initCache() { userCache.removeAll(); List<UserEntity> userList = userService.queryAllUsers(); for (UserEntity user : userList) { userCache.put(new Element(user.getUserId(), new Cache(user.getUserId(), user))); } }
/** * 清除缓存 * * @param cacheName * @return */ public boolean clearCache(String cacheName) { CacheManager cacheManagerObject = cacheManager.getObject(); Cache cache = cacheManagerObject.getCache(cacheName); if (cache != null) { cache.removeAll(); return Boolean.TRUE; } else { return Boolean.FALSE; } }
@RequestMapping("{cacheName}/clear") @ResponseBody public Object clear(@PathVariable("cacheName") String cacheName) { Cache cache = cacheManager.getCache(cacheName); cache.clearStatistics(); cache.removeAll(); return "操作成功!"; }
@Before public void initialiseCache() { MockitoAnnotations.initMocks(this); topUpStatusCache = cacheManager.getCache("topUpStatusCache"); topUpStatusCache.removeAll(); topUpStatusCache.clearStatistics(); topUpStatusCache.setStatisticsEnabled(true); underTest = new TopUpResultService( topUpStatusCache, dailyAwardPromotionService, queuePublishingService); }
public static void main(String[] args) throws Exception { Config config = new Config(); Cache cache = config.getCache(); // cache data generator sequence FixedSizeElementSequence elementSequence = new FixedSizeElementSequence(Config.NUMBER_OF_ENTRIES, Config.SIZE_OF_ENTRY); cache.removeAll(); LOG.info("cache size should be zero. size=" + cache.getSize() + "\n starting load"); Util.sleepFor(3); cache.setNodeBulkLoadEnabled(true); long start = System.currentTimeMillis(); // single threaded for now // start putting data into the cache PutWorker putWorker = new PutWorker(cache, elementSequence); // TODO:use executor to make this multi-threaded putWorker.start(); // for now, waiting for put to complete putWorker.join(); // now remove bulkmode long endOfWorkerThread = System.currentTimeMillis(); cache.setNodeBulkLoadEnabled(false); Config.CALL_TIMER.stop(); // stop the timer long endOfBulkLoadReset = System.currentTimeMillis(); int endSize = cache.getSize(); LOG.info( "complete. total time for " + Config.NUMBER_OF_ENTRIES + " puts to complete is " + (endOfWorkerThread - start) + "ms, and time it took to reset bulk mode is " + (endOfBulkLoadReset - endOfWorkerThread) + "ms \n End size=" + endSize); // just wait for return // for now, waiting for user input to close the // program. This gives us time to look at the metrics on JMX console or // TMC :) Util.waitForInput(); ConsoleReporter.enable(1, TimeUnit.SECONDS); Util.sleepFor(2); }
private void handleJGroupNotification(JGroupSerializable e) { // log.debug("got notified:"+e.getSerializableKey()); Cache c = cacheManager.getCache(e.getCacheName()); if (c != null) { if (e.getEvent() == e.REMOVE && c.getQuiet(e.getKey()) != null) { c.remove(e.getKey(), true); } else if (e.getEvent() == e.PUT) { c.put(new Element(e.getKey(), e.getValue()), true); } else if (e.getEvent() == e.REMOVE_ALL) { // c.removeAll(true); LOG.debug("remove all"); c.removeAll(true); } } }
@Override protected void runTest(Cache cache, ClusteringToolkit clusteringToolkit) throws Throwable { final int index = waitForAllClients(); Assert.assertEquals(0, cache.getSize()); waitForAllClients(); cache.put(new Element("key" + index, "value" + index)); cache.put(new Element("key" + index, "valueUpdated" + index)); cache.remove("key" + index); waitForAllClients(); cache.removeAll(); waitForAllClients(); Thread.sleep(10000); EhcacheTerracottaEventListener listener = null; Set<CacheEventListener> listeners = cache.getCacheEventNotificationService().getCacheEventListeners(); for (CacheEventListener l : listeners) { if (l instanceof EhcacheTerracottaEventListener) { listener = (EhcacheTerracottaEventListener) l; break; } } Assert.assertNotNull(listener); Assert.assertEquals(1, listener.getPut().size()); Assert.assertEquals(1, listener.getUpdate().size()); Assert.assertEquals(1, listener.getRemove().size()); Assert.assertEquals(1, listener.getRemoveAll()); }
public void clear() { ehcache.removeAll(); stats.clear(); }
/* * (non-Javadoc) * * @see javax.persistence.Cache#evictAll() */ @Override public void evictAll() { ehcache.removeAll(); }
/* * (non-Javadoc) * * @see net.jawr.web.cache.AbstractCacheManager#clear() */ public void clear() { cache.removeAll(); }
/* * (non-Javadoc) * @see org.kaleidofoundry.core.cache.Cache#removeAll() */ @Override public void clear() { cache.removeAll(); }
public void removeAll(boolean b) { cache.removeAll(b); }
public void removeAll() { cache.removeAll(); }