コード例 #1
0
 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();
 }
コード例 #2
0
ファイル: EhCache.java プロジェクト: javajiao/mg4
 public void clear() throws CacheException {
   try {
     ehcache.removeAll();
   } catch (IllegalStateException e) {
     throw new CacheException(e);
   }
 }
コード例 #3
0
ファイル: UserCache.java プロジェクト: kubbye/framework
  @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)));
    }
  }
コード例 #4
0
ファイル: CommonService.java プロジェクト: chrooter/phone-1
 /**
  * 清除缓存
  *
  * @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;
   }
 }
コード例 #5
0
  @RequestMapping("{cacheName}/clear")
  @ResponseBody
  public Object clear(@PathVariable("cacheName") String cacheName) {

    Cache cache = cacheManager.getCache(cacheName);
    cache.clearStatistics();
    cache.removeAll();

    return "操作成功!";
  }
コード例 #6
0
  @Before
  public void initialiseCache() {
    MockitoAnnotations.initMocks(this);

    topUpStatusCache = cacheManager.getCache("topUpStatusCache");
    topUpStatusCache.removeAll();
    topUpStatusCache.clearStatistics();
    topUpStatusCache.setStatisticsEnabled(true);

    underTest =
        new TopUpResultService(
            topUpStatusCache, dailyAwardPromotionService, queuePublishingService);
  }
コード例 #7
0
ファイル: Load.java プロジェクト: vinaynair/tc-labs
  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);
  }
コード例 #8
0
ファイル: JGroupManager.java プロジェクト: projetaty/kernel
  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);
      }
    }
  }
コード例 #9
0
    @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());
    }
コード例 #10
0
 public void clear() {
   ehcache.removeAll();
   stats.clear();
 }
コード例 #11
0
 /*
  * (non-Javadoc)
  *
  * @see javax.persistence.Cache#evictAll()
  */
 @Override
 public void evictAll() {
   ehcache.removeAll();
 }
コード例 #12
0
ファイル: EhCacheManager.java プロジェクト: ledermueller/jawr
 /*
  * (non-Javadoc)
  *
  * @see net.jawr.web.cache.AbstractCacheManager#clear()
  */
 public void clear() {
   cache.removeAll();
 }
コード例 #13
0
 /*
  * (non-Javadoc)
  * @see org.kaleidofoundry.core.cache.Cache#removeAll()
  */
 @Override
 public void clear() {
   cache.removeAll();
 }
コード例 #14
0
 public void removeAll(boolean b) {
   cache.removeAll(b);
 }
コード例 #15
0
 public void removeAll() {
   cache.removeAll();
 }