Skip to content

Commit

Permalink
[webui][api] update Projects::KeyInfo to use project.cache_key for ca…
Browse files Browse the repository at this point in the history
…ching
  • Loading branch information
evanrolfe committed Jan 18, 2017
1 parent 4d8e07d commit e7cfd98
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/api/app/models/project.rb
Expand Up @@ -1861,7 +1861,7 @@ def image_template?
end

def key_info
@key_info ||= KeyInfo.find_by_project_name(name)
@key_info ||= KeyInfo.find_by_project(self)
end

private
Expand Down
7 changes: 3 additions & 4 deletions src/api/app/models/project/key_info.rb
Expand Up @@ -6,10 +6,9 @@ class KeyInfo

CACHE_EXPIRY_TIME = 5.minutes

def self.find_by_project_name(project_name)
cache_key = "key_info_project_#{project_name}"
response = Rails.cache.fetch(cache_key, expires_in: CACHE_EXPIRY_TIME) do
Suse::Backend.get(backend_url(project_name)).body
def self.find_by_project(project)
response = Rails.cache.fetch("key_info_project_#{project.cache_key}", expires_in: CACHE_EXPIRY_TIME) do
Suse::Backend.get(backend_url(project.name)).body
end
parsed_response = Xmlhash.parse(response)

Expand Down

0 comments on commit e7cfd98

Please sign in to comment.