com.hazelcast.core.IMap.tryRemove()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(1.6k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中com.hazelcast.core.IMap.tryRemove()方法的一些代码示例,展示了IMap.tryRemove()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IMap.tryRemove()方法的具体详情如下:
包路径:com.hazelcast.core.IMap
类名称:IMap
方法名:tryRemove

IMap.tryRemove介绍

[英]Tries to remove the entry with the given key from this map within the specified timeout value. If the key is already locked by another thread and/or member, then this operation will wait the timeout amount for acquiring the lock.

Warning:

This method uses hashCode and equals of the binary form of the key, not the actual implementations of hashCode and equalsdefined in the key's class.

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.
[中]尝试在指定的超时值内从此映射中删除具有给定键的项。如果密钥已被其他线程和/或成员锁定,则此操作将等待获取锁的超时量。
警告:
此方法使用密钥二进制形式的hashCode和equals,而不是密钥类中定义的hashCode和equals的实际实现。
与地图商店的交互
如果配置了直写持久化模式,则在从内存中删除该值之前,将调用MapStore#delete(对象)以从映射存储中删除该值。delete引发的异常使操作失败,并传播到调用方。
如果将写后持久化模式配置为关闭写合并,则com。黑泽尔卡斯特。地图如果写后队列已达到其每个节点的最大容量,则可能引发ReacheMaxSizeException。

代码示例

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public boolean tryRemove(K key, long timeout, TimeUnit timeunit) {
  return map.tryRemove(key, timeout, timeunit);
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public void run() {
    IMap map = hazelcast.getMap("myMap");
    map.tryRemove(random.nextInt(SIZE), 10, TimeUnit.MILLISECONDS);
  }
}, 10);

相关文章