You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2014/02/05 18:23:28 UTC
couchdb commit: updated refs/heads/fauxton-data-cache to 8ec4cbc
Updated Branches:
refs/heads/fauxton-data-cache ed89f3402 -> 8ec4cbc11
Add more caching locations
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/8ec4cbc1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/8ec4cbc1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/8ec4cbc1
Branch: refs/heads/fauxton-data-cache
Commit: 8ec4cbc11e337555dd82e27e19c802bda3bcb817
Parents: ed89f34
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Feb 5 19:23:12 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Feb 5 19:23:12 2014 +0200
----------------------------------------------------------------------
src/fauxton/app/addons/databases/resources.js | 5 +++++
src/fauxton/app/addons/databases/routes.js | 2 +-
src/fauxton/app/addons/databases/views.js | 2 +-
src/fauxton/app/addons/documents/views.js | 21 +++------------------
src/fauxton/app/core/base.js | 21 ++++++++++++++++++---
src/fauxton/app/core/couchdbSession.js | 11 +++++++++--
6 files changed, 37 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/8ec4cbc1/src/fauxton/app/addons/databases/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/resources.js b/src/fauxton/app/addons/databases/resources.js
index 5fa931b..ea1aed2 100644
--- a/src/fauxton/app/addons/databases/resources.js
+++ b/src/fauxton/app/addons/databases/resources.js
@@ -171,6 +171,11 @@ function(app, FauxtonAPI, Documents) {
documentation: function(){
return "all_dbs";
},
+
+ cache: {
+ expires: 60
+ },
+
url: function(context) {
if (context === "apiurl") {
return window.location.origin + "/_all_dbs";
http://git-wip-us.apache.org/repos/asf/couchdb/blob/8ec4cbc1/src/fauxton/app/addons/databases/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/routes.js b/src/fauxton/app/addons/databases/routes.js
index c413018..131abf9 100644
--- a/src/fauxton/app/addons/databases/routes.js
+++ b/src/fauxton/app/addons/databases/routes.js
@@ -59,7 +59,7 @@ function(app, FauxtonAPI, Databases, Views) {
},
establish: function() {
- return [this.databases.fetch()];
+ return [this.databases.fetchOnce()];
}
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/8ec4cbc1/src/fauxton/app/addons/databases/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/views.js b/src/fauxton/app/addons/databases/views.js
index afe2d1c..7f23d65 100644
--- a/src/fauxton/app/addons/databases/views.js
+++ b/src/fauxton/app/addons/databases/views.js
@@ -61,7 +61,7 @@ function(app, Components, FauxtonAPI, Databases) {
var deferred = FauxtonAPI.Deferred();
FauxtonAPI.when(currentDBs.map(function(database) {
- return database.status.fetch();
+ return database.status.fetchOnce();
})).always(function(resp) {
//make this always so that even if a user is not allowed access to a database
//they will still see a list of all databases
http://git-wip-us.apache.org/repos/asf/couchdb/blob/8ec4cbc1/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index 5476203..13cbacb 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1804,30 +1804,15 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
template: "addons/documents/templates/changes",
initialize: function () {
- var that = this;
- this.listenTo( this.model.changes, 'change', function () {
- console.log('render on change');
- that.render();
- });
- this.listenTo( this.model.changes, 'cachesync', function () {
- console.log('render on cachesync');
- that.render();
- });
+ this.listenTo( this.model.changes, 'sync', this.render);
+ this.listenTo( this.model.changes, 'cachesync', this.render);
},
establish: function() {
- return [ this.model.changes.fetchOnce({prefill: true,
- success: function () {
- console.log('hi ajax success');
- },
- prefillSuccess: function () {
- console.log('hi prefill success');
- }
- })];
+ return [ this.model.changes.fetchOnce({prefill: true})];
},
serialize: function () {
- console.log('ss');
return {
changes: this.model.changes.toJSON(),
database: this.model
http://git-wip-us.apache.org/repos/asf/couchdb/blob/8ec4cbc1/src/fauxton/app/core/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/base.js b/src/fauxton/app/core/base.js
index 6fe3261..24b89cf 100644
--- a/src/fauxton/app/core/base.js
+++ b/src/fauxton/app/core/base.js
@@ -17,7 +17,6 @@ define([
],
function(Backbone, LayoutManager, BackboneCache) {
- console.log(BackboneCache);
var FauxtonAPI = {
//add default objects
router: {
@@ -81,8 +80,24 @@ function(Backbone, LayoutManager, BackboneCache) {
var caching = {
fetchOnce: function (opts) {
var options = _.defaults(opts || {}, this.cache, {cache: true});
- console.log('opts', options);
- return this.fetch(options);
+
+ if (opts && !opts.cache) {
+ delete options.cache;
+ }
+
+ if (!options.prefill) {
+ return this.fetch(options);
+ }
+
+ //With Prefill, the Caching with resolve with whatever is in the cache for that model/collection
+ //and at the sametime it will fetch from the server the latest.
+ var promise = FauxtonAPI.Deferred(),
+ fetchPromise = this.fetch(options);
+
+ fetchPromise.progress(promise.resolveWith); // Fires when the cache hit happens
+ fetchPromise.then(promise.resolveWith); // Fires after the AJAX call
+
+ return promise;
}
};
http://git-wip-us.apache.org/repos/asf/couchdb/blob/8ec4cbc1/src/fauxton/app/core/couchdbSession.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/couchdbSession.js b/src/fauxton/app/core/couchdbSession.js
index 93bfd8a..b70ddf3 100644
--- a/src/fauxton/app/core/couchdbSession.js
+++ b/src/fauxton/app/core/couchdbSession.js
@@ -29,9 +29,16 @@ function (FauxtonAPI) {
fetchUser: function (opt) {
var that = this,
- currentUser = this.user();
+ options = opt || {},
+ currentUser = this.user(),
+ fetch = this.fetchOnce;
- return this.fetchOnce(opt).then(function () {
+ if (options.forceFetch) {
+ fetch = this.fetch;
+ Backbone.fetchCache.clearItem(_.result(this.url));
+ }
+
+ return this.fetch(opt).then(function () {
var user = that.user();
// Notify anyone listening on these events that either a user has changed