本文整理了Java中com.hazelcast.core.IMap.tryPut()
方法的一些代码示例,展示了IMap.tryPut()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IMap.tryPut()
方法的具体详情如下:
包路径:com.hazelcast.core.IMap
类名称:IMap
方法名:tryPut
[英]Tries to put the given key and value into this map within a specified timeout value. If this method returns false, it means that the caller thread could not acquire the lock for the key within the timeout duration, thus the put operation is not successful.
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 no value is found with key in memory, MapLoader#load(Object) is invoked to load the value from the map store backing the map. Exceptions thrown by load fail the operation and are propagated to the caller.
If write-through persistence mode is configured, before the value is stored in memory, MapStore#store(Object,Object) is called to write the value into the map store. Exceptions thrown by the store 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.
[中]
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public boolean tryPut(K key, V value, long timeout, TimeUnit timeunit) {
return map.tryPut(key, value, timeout, timeunit);
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
public void run() {
IMap map = hazelcast.getMap("myMap");
map.tryPut(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000))), 10,
TimeUnit.MILLISECONDS);
}
}, 5);
内容来源于网络,如有侵权,请联系作者删除!