Skip to content

Commit

Permalink
Disable cache by default. Closes #672
Browse files Browse the repository at this point in the history
  • Loading branch information
dxg committed Oct 19, 2015
1 parent 9838549 commit 9df6a4e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v2.2.0
- Singleton/cache disabled by default (#672)

### v2.1.27
- Fix noisy mysql debug output (#642)

Expand Down
16 changes: 8 additions & 8 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -90,7 +90,7 @@ orm.connect("mysql://username:password@host/database", function (err, db) {
// err.msg = "under-age";
});
});

});
});
});
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -516,24 +516,24 @@ 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
});
```

and also globally:

```js
orm.connect('...', function(err, db) {
db.settings.set('instance.cache', false);
db.settings.set('instance.cache', true);
});
```

Expand Down
2 changes: 1 addition & 1 deletion lib/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var default_settings = {
required : false
},
instance : {
cache : true,
cache : false,
cacheSaveCheck : true,
autoSave : false,
autoFetch : false,
Expand Down

0 comments on commit 9df6a4e

Please sign in to comment.