本文整理了Java中com.hazelcast.core.IMap.put()
方法的一些代码示例,展示了IMap.put()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IMap.put()
方法的具体详情如下:
包路径:com.hazelcast.core.IMap
类名称:IMap
方法名:put
[英]Warning 1:
This method returns a clone of the previous value, not the original (identically equal) value previously put into the map.
Warning 2:
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.
Note: Use #set(Object,Object) if you don't need the return value, it's slightly more efficient.
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 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.
[中]警告1:
此方法返回先前值的克隆,而不是先前放入映射的原始(相同相等)值。
警告2:
此方法使用密钥二进制形式的hashCode和equals,而不是密钥类中定义的hashCode和equals的实际实现。
注意:使用#set(Object,Object)如果您不需要返回值,它会稍微更有效。
与地图商店的交互
如果在内存中找不到键的值,则会调用MapLoader#load(对象)从支持映射的映射存储中加载值。load引发的异常使操作失败,并传播到调用方。
如果配置了直写持久化模式,则在将值存储在内存中之前,将调用MapStore#store(对象,对象)将值写入映射存储。存储引发的异常使操作失败,并传播到调用方。
如果将写后持久化模式配置为关闭写合并,则com。黑泽尔卡斯特。地图如果写后队列已达到其每个节点的最大容量,则可能引发ReacheMaxSizeException。
代码示例来源:origin: mrniko/netty-socketio
@Override
public void set(String key, Object val) {
map.put(key, val);
}
代码示例来源:origin: primefaces/primefaces
@Override
public void put(String region, String key, Object object) {
IMap<String, Object> cacheRegion = getRegion(region);
cacheRegion.put(key, object);
}
代码示例来源:origin: pippo-java/pippo
@Override
public void save(SessionData sessionData) {
this.sessions.put(sessionData.getId(), sessionData);
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
public void run() {
map.put(ownedKey, createValue());
latch.countDown();
}
});
代码示例来源: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-code-samples
@RequestMapping("/put")
public CommandResponse put(@RequestParam(value = "key") String key, @RequestParam(value = "value") String value) {
IMap<String, String> map = hazelcastClient.getMap("map");
String oldValue = map.put(key, value);
return new CommandResponse(oldValue);
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
@RequestMapping("/put")
public CommandResponse put(@RequestParam(value = "key") String key, @RequestParam(value = "value") String value) {
IMap<String, String> map = hazelcastInstance.getMap("map");
String oldValue = map.put(key, value);
return new CommandResponse(oldValue);
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
public static void main(String[] args) {
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
IMap<String, Customer> map = hz.getMap("map");
map.put("1", new Customer("peter", true, 36));
map.put("2", new Customer("john", false, 40));
map.put("3", new Customer("roger", true, 20));
Set<Customer> employees = (Set<Customer>) map.values(new SqlPredicate("active AND age < 30"));
System.out.println("Employees: " + employees);
Hazelcast.shutdownAll();
}
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
private static void generateUsers(IMap<String, User> users) {
users.put("Rod", new User("Rod", 19, true));
users.put("Jane", new User("Jane", 20, true));
users.put("Freddy", new User("Freddy", 23, true));
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
private static void generateUsers(IMap<String, User> users) {
users.put("Rod", new User("Rod", 19, true));
users.put("Jane", new User("Jane", 20, true));
users.put("Freddy", new User("Freddy", 23, true));
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
@RequestMapping("/put")
public CommandResponse put(@RequestParam(value = "key") String key, @RequestParam(value = "value") String value) {
IMap<String, String> map = hazelcastInstance.getMap("map");
String oldValue = map.put(key, value);
return new CommandResponse(oldValue);
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
@RequestMapping("/populate")
public CommandResponse populate() {
IMap<String, String> map = hazelcastInstance.getMap("map");
for (int i = 0; i < 1000; i++) {
String s = Integer.toString(i);
map.put(s, s);
}
return new CommandResponse("1000 entry inserted to the map");
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
public void run() {
IMap map = hazelcast.getMap("myMap");
map.put(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000))));
}
}, 50);
代码示例来源:origin: hazelcast/hazelcast-code-samples
@RequestMapping("/put")
public CommandResponse put(@RequestParam(value = "key") String key, @RequestParam(value = "value") String value) {
IMap<String, String> map = hazelcastInstance.getMap("map");
String oldValue = map.put(key, value);
return new CommandResponse(oldValue);
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
@RequestMapping("/populate")
public CommandResponse populate() {
IMap<String, String> map = hazelcastInstance.getMap("map");
for (int i = 0; i < 1000; i++) {
String s = Integer.toString(i);
map.put(s, s);
}
return new CommandResponse("1000 entry inserted to the map");
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
public static void main(String[] args) {
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
IMap<Long, Person> personMap = hz.getMap("personMap");
personMap.put(1L, new Person(1L, "Peter"));
hz.shutdown();
}
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
public static void main(String[] args) {
HazelcastInstance instance = Hazelcast.newHazelcastInstance();
IMap<String, Person> binaryMap = instance.getMap("binaryMap");
IMap<String, Person> objectMap = instance.getMap("objectMap");
Person person = new Person();
binaryMap.put("peter", person);
objectMap.put("peter", person);
System.out.println(person == binaryMap.get("peter"));
System.out.println(binaryMap.get("peter") == binaryMap.get("peter"));
System.out.println(person == objectMap.get("peter"));
System.out.println(objectMap.get("peter") == objectMap.get("peter"));
}
代码示例来源:origin: apache/cxf
public void add(String identifier, SecurityToken token) {
if (token != null && !StringUtils.isEmpty(identifier)) {
int parsedTTL = getTTL(token);
if (parsedTTL > 0) {
getCacheMap().put(identifier, token, parsedTTL, TimeUnit.SECONDS);
}
}
}
代码示例来源:origin: org.apache.cxf.services.sts/cxf-services-sts-core
public void add(String identifier, SecurityToken token) {
if (token != null && !StringUtils.isEmpty(identifier)) {
int parsedTTL = getTTL(token);
if (parsedTTL > 0) {
getCacheMap().put(identifier, token, parsedTTL, TimeUnit.SECONDS);
}
}
}
代码示例来源:origin: apache/cxf
public void add(SecurityToken token) {
if (token != null && !StringUtils.isEmpty(token.getId())) {
int parsedTTL = getTTL(token);
if (parsedTTL > 0) {
getCacheMap().put(token.getId(), token, parsedTTL, TimeUnit.SECONDS);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!