本文整理汇总了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();
}
}