@CheckForNull
private <T extends Document> T findUncached(Collection<T> collection, String key, DocumentReadPreference docReadPref) {
DBCollection dbCollection = getDBCollection(collection);
long start = start();
try {
ReadPreference readPreference = getMongoReadPreference(collection, Utils.getParentId(key), docReadPref);
if(readPreference.isSlaveOk()){
LOG.trace("Routing call to secondary for fetching [{}]", key);
}
DBObject obj = dbCollection.findOne(getByKeyQuery(key).get(), null, null, readPreference);
if (obj == null
&& readPreference.isSlaveOk()) {
//In case secondary read preference is used and node is not found
//then check with primary again as it might happen that node document has not been
//replicated. This is required for case like SplitDocument where the SplitDoc is fetched with
//maxCacheAge == Integer.MAX_VALUE which results in readPreference of secondary.
//In such a case we know that document with such an id must exist