本文整理了Java中com.hazelcast.core.IMap.delete()
方法的一些代码示例,展示了IMap.delete()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IMap.delete()
方法的具体详情如下:
包路径:com.hazelcast.core.IMap
类名称:IMap
方法名:delete
[英]Removes the mapping for the key from this map if it is present.
Unlike #remove(Object), this operation does not return the removed value, which avoids the serialization and network transfer cost of the returned value. If the removed value will not be used, this operation is preferred over the remove operation for better performance.
The map will not contain a mapping for the specified key once the call returns.
Warning:
This method breaks the contract of EntryListener. When an entry is removed by delete(), it fires an EntryEvent with a null oldValue.
Also, a listener with predicates will have null values, so only keys can be queried via predicates.
Interactions with the map store
If write-through persistence mode is configured, before the value is removed from the the memory, MapStore#delete(Object)is called to remove the value from the map store. Exceptions thrown by delete fail the operation and are propagated to the caller.
If write-behind persistence mode is configured with write-coalescing turned off, com.hazelcast.map.ReachedMaxSizeException may be thrown if the write-behind queue has reached its per-node maximum capacity.
[中]从该映射中删除密钥的映射(如果存在)。
与#remove(Object)不同,此操作不返回删除的值,从而避免了返回值的序列化和网络传输成本。如果不使用删除的值,则此操作优于删除操作,以获得更好的性能。
一旦调用返回,映射将不包含指定键的映射。
警告:
此方法打破了EntryListener的约定。当delete()删除一个条目时,它将触发一个具有null oldValue的EntryEvent。
此外,具有谓词的侦听器将具有空值,因此只能通过谓词查询键。
与地图商店的交互
如果配置了直写持久化模式,则在从内存中删除该值之前,将调用MapStore#delete(对象)以从映射存储中删除该值。delete引发的异常使操作失败,并传播到调用方。
如果将写后持久化模式配置为关闭写合并,则com。黑泽尔卡斯特。地图如果写后队列已达到其每个节点的最大容量,则可能引发ReacheMaxSizeException。
代码示例来源:origin: mrniko/netty-socketio
@Override
public void del(String key) {
map.delete(key);
}
代码示例来源:origin: spring-projects/spring-session
@Override
public void save(HazelcastSession session) {
if (session.isNew) {
this.sessions.set(session.getId(), session.getDelegate(),
session.getMaxInactiveInterval().getSeconds(), TimeUnit.SECONDS);
}
else if (session.sessionIdChanged) {
this.sessions.delete(session.originalId);
session.originalId = session.getId();
this.sessions.set(session.getId(), session.getDelegate(),
session.getMaxInactiveInterval().getSeconds(), TimeUnit.SECONDS);
}
else if (session.hasChanges()) {
SessionUpdateEntryProcessor entryProcessor = new SessionUpdateEntryProcessor();
if (session.lastAccessedTimeChanged) {
entryProcessor.setLastAccessedTime(session.getLastAccessedTime());
}
if (session.maxInactiveIntervalChanged) {
if (SUPPORTS_SET_TTL) {
updateTtl(session);
}
entryProcessor.setMaxInactiveInterval(session.getMaxInactiveInterval());
}
if (!session.delta.isEmpty()) {
entryProcessor.setDelta(session.delta);
}
this.sessions.executeOnKey(session.getId(), entryProcessor);
}
session.clearChangeFlags();
}
代码示例来源:origin: com.hazelcast/hazelcast-all
@Override
public void evict(Object key) {
if (key != null) {
map.delete(key);
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public void evict(Object key) {
if (key != null) {
map.delete(key);
}
}
代码示例来源:origin: com.hazelcast.jet/hazelcast-jet-spring
@Override
public void evict(Object key) {
if (key != null) {
map.delete(key);
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public void delete(Object key) {
map.delete(key);
}
代码示例来源:origin: com.hazelcast/hazelcast-all
@Override
public void delete(K key) {
map.delete(key);
}
代码示例来源:origin: com.corundumstudio.socketio/netty-socketio
@Override
public void del(String key) {
map.delete(key);
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public void delete(K key) {
map.delete(key);
}
代码示例来源:origin: com.erudika/para
@Override
public void remove(String appid, String id) {
if (!StringUtils.isBlank(id) && !StringUtils.isBlank(appid)) {
logger.debug("Cache.remove() {} {}", appid, id);
client().getMap(appid).delete(id);
}
}
代码示例来源:origin: com.erudika/para
@Override
public void removeAll(String appid, List<String> ids) {
if (ids != null && !StringUtils.isBlank(appid)) {
IMap<?,?> map = client().getMap(appid);
for (String id : ids) {
if (!StringUtils.isBlank(id)) {
map.delete(id);
}
}
logger.debug("Cache.removeAll() {} {}", appid, ids.size());
}
}
代码示例来源:origin: lukas-krecan/ShedLock
private void removeLock(final String lockName) {
getStore().delete(lockName);
log.debug("lock store - lock deleted : {}", lockName);
}
代码示例来源:origin: stevensouza/jamonapi
@Override
public void remove(String instanceKey) {
intitialize();
jamonDataMap.delete(instanceKey);
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
public static void main(String[] args) {
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
IMap<String, String> map = hz.getMap("someMap");
String key = "" + System.nanoTime();
String value = "1";
map.put(key, value);
map.put(key, "2");
map.delete(key);
System.exit(0);
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
protected void handleMapDelete(String[] args) {
getMap().delete(args[1]);
println("true");
}
代码示例来源:origin: vgoldin/cqrs-eventsourcing-kafka
@Override
public void handle(InventoryItemDeactivated event) {
IMap<String, InventoryItemListItem> inventoryItems = getInventoryItemsMap();
String id = event.id.toString();
inventoryItems.delete(id);
}
代码示例来源:origin: com.hazelcast/hazelcast-all
protected void handleMapDelete(String[] args) {
getMap().delete(args[1]);
println("true");
}
代码示例来源:origin: networknt/light-oauth2
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
String clientId = exchange.getQueryParameters().get("clientId").getFirst();
IMap<String, Client> clients = CacheStartupHookProvider.hz.getMap("clients");
if(clients.get(clientId) == null) {
setExchangeStatus(exchange, CLIENT_NOT_FOUND, clientId);
} else {
clients.delete(clientId);
}
processAudit(exchange);
}
代码示例来源:origin: networknt/light-oauth2
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
String userId = exchange.getQueryParameters().get("userId").getFirst();
IMap<String, User> users = CacheStartupHookProvider.hz.getMap("users");
if(users.get(userId) == null) {
setExchangeStatus(exchange, USER_NOT_FOUND, userId);
} else {
users.delete(userId);
}
processAudit(exchange);
}
}
代码示例来源:origin: networknt/light-oauth2
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
String providerId = exchange.getQueryParameters().get("providerId").getFirst();
IMap<String, Provider> providers = CacheStartupHookProvider.hz.getMap("providers");
if(providers.get(providerId) == null) {
setExchangeStatus(exchange, PROVIDER_ID_NOT_EXISTING, providerId);
} else {
providers.delete(providerId);
}
processAudit(exchange);
}
内容来源于网络,如有侵权,请联系作者删除!