diff --git a/shared_realm.cpp b/shared_realm.cpp index fe97d8b3..7a2e7be0 100644 --- a/shared_realm.cpp +++ b/shared_realm.cpp @@ -29,7 +29,7 @@ using namespace realm; RealmCache Realm::s_global_cache; -Realm::Config::Config(const Config& c) : path(c.path), read_only(c.read_only), in_memory(c.in_memory), schema_version(c.schema_version), migration_function(c.migration_function) +Realm::Config::Config(const Config& c) : path(c.path), read_only(c.read_only), in_memory(c.in_memory), cache(c.cache), schema_version(c.schema_version), migration_function(c.migration_function) { if (c.schema) { schema = std::make_unique(*c.schema); @@ -132,7 +132,9 @@ SharedRealm Realm::get_shared_realm(Config &config) realm->update_schema(*realm->m_config.schema, realm->m_config.schema_version); } - s_global_cache.cache_realm(realm, realm->m_thread_id); + if (config.cache) { + s_global_cache.cache_realm(realm, realm->m_thread_id); + } return realm; } diff --git a/shared_realm.hpp b/shared_realm.hpp index 3ddfb5a5..5c74e13d 100644 --- a/shared_realm.hpp +++ b/shared_realm.hpp @@ -44,6 +44,7 @@ namespace realm { std::string path; bool read_only = false; bool in_memory = false; + bool cache = true; std::unique_ptr encryption_key; std::unique_ptr schema;