[ARVADOS] updated: 15bc31fe70042ac6235d9984f8a116b8640b92c4
git at public.curoverse.com
git at public.curoverse.com
Tue Feb 4 16:21:02 EST 2014
Summary of changes:
.../app/controllers/application_controller.rb | 2 ++
apps/workbench/app/models/arvados_base.rb | 14 ++++++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
via 15bc31fe70042ac6235d9984f8a116b8640b92c4 (commit)
from 7f2449727f36a2687f22be1b3587674a2eb8c7ed (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 15bc31fe70042ac6235d9984f8a116b8640b92c4
Author: Tom Clegg <tom at curoverse.com>
Date: Tue Feb 4 13:18:08 2014 -0800
Skip repeated find() calls for the same object during a single page
request.
diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 3f495ca..27a4f79 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -157,7 +157,9 @@ class ApplicationController < ActionController::Base
def thread_clear
Thread.current[:arvados_api_token] = nil
Thread.current[:user] = nil
+ Rails.cache.delete_matched(/^request_#{Thread.current.object_id}_/)
yield
+ Rails.cache.delete_matched(/^request_#{Thread.current.object_id}_/)
end
def thread_with_api_token(login_optional = false)
diff --git a/apps/workbench/app/models/arvados_base.rb b/apps/workbench/app/models/arvados_base.rb
index 6b5ee81..72b76a5 100644
--- a/apps/workbench/app/models/arvados_base.rb
+++ b/apps/workbench/app/models/arvados_base.rb
@@ -68,11 +68,21 @@ class ArvadosBase < ActiveRecord::Base
self.columns
@attribute_info
end
- def self.find(uuid)
+ def self.find(uuid, opts={})
if uuid.class != String or uuid.length < 27 then
raise 'argument to find() must be a uuid string. Acceptable formats: warehouse locator or string with format xxxxx-xxxxx-xxxxxxxxxxxxxxx'
end
- new.private_reload(uuid)
+
+ # Only do one lookup on the API side per {class, uuid, workbench
+ # request} unless {cache: false} is given via opts.
+ cache_key = "request_#{Thread.current.object_id}_#{self.to_s}_#{uuid}"
+ if opts[:cache] == false
+ Rails.cache.write cache_key, $arvados_api_client.api(self, '/' + uuid)
+ end
+ hash = Rails.cache.fetch cache_key do
+ $arvados_api_client.api(self, '/' + uuid)
+ end
+ new.private_reload(hash)
end
def self.order(*args)
ArvadosResourceList.new(self).order(*args)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list