Skip to content

Commit

Permalink
Scope cache keys to v3 (#5285)
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad authored Jun 23, 2023
1 parent 5305517 commit 0e55865
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/locales_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LocalesController < ApiController
# GET /api/v1/locales
# Returns a cached list of locales available
def index
language_with_name = Rails.cache.fetch('locales/list', expires_in: 24.hours) do
language_with_name = Rails.cache.fetch('v3/locales/list', expires_in: 24.hours) do
language_hash = {}

languages = Dir.entries(Rails.root.join('app/assets/locales')).select { |file_name| file_name.ends_with?('.json') }
Expand Down
2 changes: 1 addition & 1 deletion app/services/provider_credentials.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def call

# Cache the response for an hour
# fetch will return the value if already cached, if not, it will compute the value, cache it, then return it
Rails.cache.fetch("#{@provider}/#{@route}", expires_in: 1.hour) do
Rails.cache.fetch("v3/#{@provider}/#{@route}", expires_in: 1.hour) do
url = URI.parse("#{@endpoint}#{@route}?#{encoded_params}&checksum=#{checksum}")
res = Net::HTTP.get_response(url)

Expand Down
2 changes: 1 addition & 1 deletion spec/services/provider_credentials_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
service.call

expect(service.call).to eq(['https://test.com', 'secret'])
expect(Rails.cache.read('bbb/getUser')).to eq(['https://test.com', 'secret'])
expect(Rails.cache.read('v3/bbb/getUser')).to eq(['https://test.com', 'secret'])
end
end
end
Expand Down

0 comments on commit 0e55865

Please sign in to comment.