Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A512510081 for ; Fri, 7 Mar 2014 00:19:17 +0000 (UTC) Received: (qmail 37906 invoked by uid 500); 7 Mar 2014 00:18:06 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 37206 invoked by uid 500); 7 Mar 2014 00:17:50 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 36914 invoked by uid 99); 7 Mar 2014 00:17:45 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Mar 2014 00:17:45 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id DB52593A1EE; Fri, 7 Mar 2014 00:17:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dch@apache.org To: commits@couchdb.apache.org Date: Fri, 07 Mar 2014 00:17:49 -0000 Message-Id: <521f45d55ed34c118d898422549a6974@git.apache.org> In-Reply-To: <9b6ec795d075458aa14b487352cd8036@git.apache.org> References: <9b6ec795d075458aa14b487352cd8036@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [06/50] [abbrv] couchdb commit: updated refs/heads/2041-update-ibrowse to 948e7d9 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/2041-update-ibrowse Commit: 8ec4cbc11e337555dd82e27e19c802bda3bcb817 Parents: ed89f34 Author: Garren Smith Authored: Wed Feb 5 19:23:12 2014 +0200 Committer: Garren Smith 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