Reputation: 819
I am use GridGain as my persistence database. I have following requirements.
For 1, I saw cache.putIfAbsent(key, value)
method to insert single record if not exists. But I didn't find cache.putAllIfAbsent(Map<key, value>)
like method. I can you loop to insert multiple records one by one. Is it given performance issue?
For 2, I think I can use cache.putAll(Map<key, value>)
method. If it proper way?
I run server in Google cloud Kubernetes engine as thick clients.
Upvotes: 0
Views: 92
Reputation: 8986
putAll
always overwrites existing recordsputIfAbsent
in a loop will be slower than putAll
. Measure your specific use case to see by how muchIf there is no requirement for ordering and atomicity, DataStreamer is a good choice. When allowOverwrite
flag is false (default), you get putIfAbsent
behavior, and good performance.
try (IgniteDataStreamer<Integer, String> stmr = ignite.dataStreamer("myCache")) {
stmr.allowOverwrite(false); // Don't overwrite existing data
Map<Integer, String> entries = getMydata()
stmr.addData(entries);
}
Upvotes: 3