本文整理匯總了Java中com.hazelcast.core.IMap.clear方法的典型用法代碼示例。如果您正苦於以下問題:Java IMap.clear方法的具體用法?Java IMap.clear怎麽用?Java IMap.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hazelcast.core.IMap
的用法示例。
在下文中一共展示了IMap.clear方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resetLimit
import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@Override
public boolean resetLimit(String key) {
IMap<Object, Object> map = hz.getMap(key);
if (map == null || map.isEmpty()) {
return false;
}
map.clear();
map.destroy();
return true;
}
示例2: clearAllCaches
import com.hazelcast.core.IMap; //導入方法依賴的package包/類
public void clearAllCaches(){
final Collection<DistributedObject> distributedObjects = hazelcastInstance.getDistributedObjects();
for (DistributedObject distributedObject : distributedObjects) {
if (distributedObject instanceof IMap) {
final IMap<?, ?> map = (IMap) distributedObject;
map.clear();
}
}
}
示例3: clearAllCachesExcept
import com.hazelcast.core.IMap; //導入方法依賴的package包/類
public void clearAllCachesExcept(List<String> cacheRegions){
final Collection<DistributedObject> distributedObjects = hazelcastInstance.getDistributedObjects();
for (DistributedObject distributedObject : distributedObjects) {
if (distributedObject instanceof IMap) {
final IMap<?, ?> map = (IMap) distributedObject;
String region = map.getName();
boolean exists = cacheRegions.stream().filter(s->region.contains(s)).count()>0;
if(!exists) {
map.clear();
}
}
}
}
示例4: clear
import com.hazelcast.core.IMap; //導入方法依賴的package包/類
public void clear() {
IMap<String, byte[]> taskCache = hazelcastInstance.getMap("gradle-task-cache");
taskCache.clear();
}
示例5: clearInstanceMap
import com.hazelcast.core.IMap; //導入方法依賴的package包/類
/**
* Clears this instance Map.
*/
public <K, V> void clearInstanceMap() {
IMap<K, V> cached = hzInstance.getMap(instanceMapName());
cached.clear();
}
示例6: setup
import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@Before
public void setup() throws Exception {
ContainerContext cc = CONTAINER_CONTEXT_MAP.get(getClass());
// if configuration is changed, we need to stop containers and cc should equals to null
if (cc != null) {
if (!cc.serverXml1.equals(serverXml1) || !cc.serverXml2.equals(serverXml2)) {
cc.server1.stop();
cc.server2.stop();
cc.server1 = null;
cc.server2 = null;
cc = null;
}
}
// If container is not exist yet or
// Hazelcast instance is not active (because of such as server shutdown)
if (cc == null) {
// Build a new instance
ensureInstanceIsUp();
CONTAINER_CONTEXT_MAP.put(
getClass(),
new ContainerContext(
this,
serverXml1,
serverXml2,
serverPort1,
serverPort2,
server1,
server2,
hz));
} else {
// For every test method a different test class can be constructed for parallel runs by JUnit.
// So container can be exist, but configurations of current test may not be exist.
// For this reason, we should copy container context information (such as ports, servers, ...)
// to current test.
cc.copyInto(this);
// Ensure that instance is up and running
ensureInstanceIsUp();
// After ensuring that system is up, new containers or instance may be created.
// So, we should copy current information from test to current context.
cc.copyFrom(this);
}
// Clear map
IMap<String, Object> map = hz.getMap(DEFAULT_MAP_NAME);
map.clear();
}