repo.registerLifecycle(underlying);
MongoConnector mongoConnector = getMongoConnector();
CacheManager cacheManager = getCacheManager();
if (mongoConnector != null) {
MongoDBInvalidFieldCachingReferenceDataProvider fieldCached = new MongoDBInvalidFieldCachingReferenceDataProvider(underlying, mongoConnector);
return new MongoDBValueCachingReferenceDataProvider(fieldCached, mongoConnector);
} else if (cacheManager != null) {
ReferenceDataProvider fieldCached = new InMemoryInvalidFieldCachingReferenceDataProvider(underlying); // TODO: EHcached version
return new EHValueCachingReferenceDataProvider(fieldCached, cacheManager);