Add the ability to bypass the Realm cache entirely

This commit is contained in:
Thomas Goyne 2015-09-01 10:59:28 -07:00
parent 3f226cf342
commit 65e1eb5d08

View File

@ -90,8 +90,8 @@ Group *Realm::read_group()
SharedRealm Realm::get_shared_realm(Config config)
{
SharedRealm realm = s_global_cache.get_realm(config.path);
if (realm) {
if (config.cache) {
if (SharedRealm realm = s_global_cache.get_realm(config.path)) {
if (realm->config().read_only != config.read_only) {
throw MismatchedConfigException("Realm at path already opened with different read permissions.");
}
@ -108,13 +108,13 @@ SharedRealm Realm::get_shared_realm(Config config)
/*if (realm->config().schema != config.schema) {
throw MismatchedConfigException("Realm at path already opened with different schema");
}*/
realm->m_config.migration_function = config.migration_function;
return realm;
}
}
realm = SharedRealm(new Realm(std::move(config)));
SharedRealm realm(new Realm(std::move(config)));
// we want to ensure we are only initializing a single realm at a time
static std::mutex s_init_mutex;