當前位置: 首頁>>代碼示例>>Java>>正文


Java Cache.invalidateAll方法代碼示例

本文整理匯總了Java中com.google.common.cache.Cache.invalidateAll方法的典型用法代碼示例。如果您正苦於以下問題:Java Cache.invalidateAll方法的具體用法?Java Cache.invalidateAll怎麽用?Java Cache.invalidateAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.cache.Cache的用法示例。


在下文中一共展示了Cache.invalidateAll方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testStatementLifecycle

import com.google.common.cache.Cache; //導入方法依賴的package包/類
@Test public void testStatementLifecycle() throws Exception {
  ConnectionSpec.getDatabaseLock().lock();
  try (AvaticaConnection connection = (AvaticaConnection) getLocalConnection()) {
    Map<Integer, AvaticaStatement> clientMap = connection.statementMap;
    Cache<Integer, Object> serverMap = getLocalConnectionInternals()
        .getRemoteStatementMap(connection);
    // Other tests being run might leave statements in the cache.
    // The lock guards against more statements being cached during the test.
    serverMap.invalidateAll();
    assertEquals(0, clientMap.size());
    assertEquals(0, serverMap.size());
    Statement stmt = connection.createStatement();
    assertEquals(1, clientMap.size());
    assertEquals(1, serverMap.size());
    stmt.close();
    assertEquals(0, clientMap.size());
    assertEquals(0, serverMap.size());
  } finally {
    ConnectionSpec.getDatabaseLock().unlock();
  }
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:22,代碼來源:RemoteDriverTest.java

示例2: testConnectionIsolation

import com.google.common.cache.Cache; //導入方法依賴的package包/類
@Test public void testConnectionIsolation() throws Exception {
  ConnectionSpec.getDatabaseLock().lock();
  try {
    Cache<String, Connection> connectionMap = getLocalConnectionInternals()
        .getRemoteConnectionMap((AvaticaConnection) getLocalConnection());
    // Other tests being run might leave connections in the cache.
    // The lock guards against more connections being cached during the test.
    connectionMap.invalidateAll();

    final String sql = "select * from (values (1, 'a'))";
    assertEquals("connection cache should start empty",
        0, connectionMap.size());
    Connection conn1 = getLocalConnection();
    Connection conn2 = getLocalConnection();
    assertEquals("we now have two connections open",
        2, connectionMap.size());
    PreparedStatement conn1stmt1 = conn1.prepareStatement(sql);
    assertEquals(
        "creating a statement does not cause new connection",
        2, connectionMap.size());
    PreparedStatement conn2stmt1 = conn2.prepareStatement(sql);
    assertEquals(
        "creating a statement does not cause new connection",
        2, connectionMap.size());
    AvaticaPreparedStatement s1 = (AvaticaPreparedStatement) conn1stmt1;
    AvaticaPreparedStatement s2 = (AvaticaPreparedStatement) conn2stmt1;
    assertFalse("connection id's should be unique",
        s1.handle.connectionId.equalsIgnoreCase(s2.handle.connectionId));
    conn2.close();
    assertEquals("closing a connection closes the server-side connection",
        1, connectionMap.size());
    conn1.close();
    assertEquals("closing a connection closes the server-side connection",
        0, connectionMap.size());
  } finally {
    ConnectionSpec.getDatabaseLock().unlock();
  }
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:39,代碼來源:RemoteDriverTest.java

示例3: clearConfigCache

import com.google.common.cache.Cache; //導入方法依賴的package包/類
/**
 * Clear config cache
 */
protected void clearConfigCache() {
  synchronized (this) {
    for (Cache c : allCaches) {
      if (c != null) {
        c.invalidateAll();
      }
    }
    m_configVersion.incrementAndGet();
  }
}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:14,代碼來源:AbstractConfig.java

示例4: invalidateAll

import com.google.common.cache.Cache; //導入方法依賴的package包/類
public void invalidateAll() {
    for(Cache<Object, Object> subcache : cache.asMap().values()) {
        subcache.invalidateAll();
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:6,代碼來源:InMemoryTaskArtifactCache.java

示例5: deleteOAuthTokensEvent

import com.google.common.cache.Cache; //導入方法依賴的package包/類
@Override
public void deleteOAuthTokensEvent(DeleteOAuthTokensEvent event)
{
	Cache<String, OAuthUserState> userCache = getUserCache(CurrentInstitution.get());
	userCache.invalidateAll(event.getTokens());
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:7,代碼來源:OAuthWebServiceImpl.java

示例6: remove

import com.google.common.cache.Cache; //導入方法依賴的package包/類
public void remove(String cacheName, String key) {
    Cache<String, Object> cache = getCacheHolder(cacheName);
    if (cache != null) {
        cache.invalidateAll();
    }
}
 
開發者ID:warlock-china,項目名稱:azeroth,代碼行數:7,代碼來源:GuavaLevel1CacheProvider.java

示例7: clearAll

import com.google.common.cache.Cache; //導入方法依賴的package包/類
public void clearAll() {
    for (Cache<String, Object> cache : caches.values()) {
        cache.invalidateAll();
    }
}
 
開發者ID:warlock-china,項目名稱:azeroth,代碼行數:6,代碼來源:GuavaLevel1CacheProvider.java


注:本文中的com.google.common.cache.Cache.invalidateAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。