From 9df6a4ebb55a484a50b911005abcf982902b2984 Mon Sep 17 00:00:00 2001 From: Arek W Date: Tue, 20 Oct 2015 10:35:40 +1100 Subject: [PATCH] Disable cache by default. Closes #672 --- Changelog.md | 3 +++ Readme.md | 16 ++++++++-------- lib/Settings.js | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index 563ce79a..0c96f840 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,6 @@ +### v2.2.0 +- Singleton/cache disabled by default (#672) + ### v2.1.27 - Fix noisy mysql debug output (#642) diff --git a/Readme.md b/Readme.md index 3a9fc57d..c55cb64f 100755 --- a/Readme.md +++ b/Readme.md @@ -70,7 +70,7 @@ orm.connect("mysql://username:password@host/database", function (err, db) { }); // add the table to the database - db.sync(function(err) { + db.sync(function(err) { if (err) throw err; // add a row to the person table @@ -90,7 +90,7 @@ orm.connect("mysql://username:password@host/database", function (err, db) { // err.msg = "under-age"; }); }); - + }); }); }); @@ -278,7 +278,7 @@ var Person = db.define("person", { Other options: -- `cache` : (default: `true`) Set it to `false` to disable Instance cache ([Singletons](#singleton)) or set a timeout value (in seconds); +- `cache` : (default: `false`) Set it to `true` to enable Instance cache ([Singletons](#singleton)) or set a timeout value (in seconds); - `autoSave` : (default: `false`) Set it to `true` to save an Instance right after changing any property; - `autoFetch` : (default: `false`) Set it to `true` to fetch associations when fetching an instance from the database; - `autoFetchLimit` : (default: `1`) If `autoFetch` is enabled this defines how many hoops (associations of associations) @@ -516,16 +516,16 @@ db.driver.execQuery( ### Caching & Integrity -Model instances are cached. If multiple different queries will result in the same result, you will +Model instances can be cached (turned off by default). If enabled, multiple different queries will result in the same result - you will get the same object. If you have other systems that can change your database (or you're developing and need -to make some manual changes) you should remove this feature by disabling cache. This can be done when you're -defining the Model. +to make some manual changes) you shouldn't use this feature. +It can be enabled/disabled per model: ```js var Person = db.define('person', { name : String }, { - cache : false + cache : true }); ``` @@ -533,7 +533,7 @@ and also globally: ```js orm.connect('...', function(err, db) { - db.settings.set('instance.cache', false); + db.settings.set('instance.cache', true); }); ``` diff --git a/lib/Settings.js b/lib/Settings.js index 1fddd384..c054a672 100644 --- a/lib/Settings.js +++ b/lib/Settings.js @@ -6,7 +6,7 @@ var default_settings = { required : false }, instance : { - cache : true, + cache : false, cacheSaveCheck : true, autoSave : false, autoFetch : false,