try {
Map<String, NodeDocument> cachedDocs = Collections.emptyMap();
if (collection == Collection.NODES) {
cachedDocs = Maps.newHashMap();
for (String key : keys) {
cachedDocs.put(key, nodesCache.getIfPresent(new StringValue(key)));
}
}
try {
WriteResult writeResult = dbCollection.update(query.get(), update, false, true, WriteConcern.SAFE);
if (writeResult.getError() != null) {
throw new MicroKernelException("Update failed: " + writeResult.getError());
}
// update cache
for (Entry<String, NodeDocument> entry : cachedDocs.entrySet()) {
Lock lock = getAndLock(entry.getKey());
try {
if (entry.getValue() == null) {
// make sure concurrently loaded document is invalidated
nodesCache.invalidate(new StringValue(entry.getKey()));
} else {
applyToCache(Collection.NODES, entry.getValue(),
updateOp.clone(entry.getKey()));
}
} finally {