Skip to content

Commit

Permalink
Merge pull request #3871 from alphagov/popular_tasks_cache
Browse files Browse the repository at this point in the history
Cache most viewed tasks for 12 hours
  • Loading branch information
hannako authored Dec 2, 2024
2 parents 8fe9429 + 7873421 commit 48a012c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/lib/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def self.content_store
@content_store ||= GdsApi::ContentStore.new(Plek.new.find("content-store"))
end

def self.cached_search(params, metric_key: "search.request_time")
Rails.cache.fetch(params, expires_in: 5.minutes) do
def self.cached_search(params, metric_key: "search.request_time", expires_in: 5.minutes)
Rails.cache.fetch(params, expires_in:) do
GovukStatsd.time(metric_key) do
search_api.search(params).to_h
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/popular_list_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def search_response
order: "-popularity",
fields: SearchApiFields::POPULAR_BROWSE_SEARCH_FIELDS,
}
Services.cached_search(params)
Services.cached_search(params, expires_in: 12.hours)
rescue GdsApi::HTTPServerError
{}
end
Expand Down

0 comments on commit 48a012c

Please sign in to comment.