Skip to content

Commit

Permalink
Merge pull request #380 from IU-Libraries-Joint-Development/essi-1552…
Browse files Browse the repository at this point in the history
…_cache_holding_loc

Cache data from holding location service
  • Loading branch information
dlpierce authored Jan 19, 2022
2 parents 1fa5484 + 97dff25 commit e140ddc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/services/holding_location_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ def self.select_options
end

def self.select_all_options
authority.all.map { |element| [element[:label], element[:code]] }
results = Rails.cache.fetch('HoldLoc-v1-_ALL_', expires_in: 1.hour, race_condition_ttl: 1.hour) do
authority.all
end
results.map { |element| [element[:label], element[:code]] }
end

def self.find(id)
authority.find(id)
Rails.cache.fetch("HoldLoc-v1-#{id}", expires_in: 1.hour, race_condition_ttl: 1.hour) do
authority.find(id)
end
end
end

0 comments on commit e140ddc

Please sign in to comment.