Skip to content

Commit

Permalink
Merge pull request #1198 from sul-dlss/cache-data
Browse files Browse the repository at this point in the history
Cache data rather than ruby object
  • Loading branch information
corylown authored Jul 1, 2024
2 parents c228442 + 07e9496 commit b02cb7c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/cocina.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ class Cocina
THUMBNAIL_MIME_TYPE = 'image/jp2'

def self.find(druid)
Rails.cache.fetch("purl/#{druid}.json", expires_in: 10.minutes) do
data = Rails.cache.fetch("purl/#{druid}.json", expires_in: 10.minutes) do
benchmark "Fetching public json for #{druid}" do
response = Faraday.get(public_json_url(druid))
raise Purl::Exception, response.status unless response.success?

new(JSON.parse(response.body))
JSON.parse(response.body)
end
end
new(data)
end

def self.public_json_url(druid)
Expand Down

0 comments on commit b02cb7c

Please sign in to comment.