本文整理匯總了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();
}
}
示例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();
}
}
示例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();
}
}
示例4: invalidateAll
import com.google.common.cache.Cache; //導入方法依賴的package包/類
public void invalidateAll() {
for(Cache<Object, Object> subcache : cache.asMap().values()) {
subcache.invalidateAll();
}
}
示例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());
}
示例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();
}
}
示例7: clearAll
import com.google.common.cache.Cache; //導入方法依賴的package包/類
public void clearAll() {
for (Cache<String, Object> cache : caches.values()) {
cache.invalidateAll();
}
}