Skip to content

Commit

Permalink
upgrade the dalli gem
Browse files Browse the repository at this point in the history
  • Loading branch information
wendelfabianchinsamy committed Apr 4, 2024
1 parent 5b46f26 commit b5cf621
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ gem "bootsnap", "~> 1.2", ">= 1.2.1"
gem "cancancan", "~> 2.0"
gem "countries", "~> 2.1", ">= 2.1.2"
gem "country_select", "~> 3.1"
gem "dalli", "~> 2.7.6"
gem "dalli", "~> 3.2", ">= 3.2.8"
gem "dotenv"
gem "equivalent-xml", "~> 0.6.0"
gem "facets", require: false
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/index_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ class IndexController < ApplicationController
def index
render plain: ENV["SITE_TITLE"]
end

def show
id = params[:id]
foo = Rails.cache.fetch("wendel/#{id}", expires_in: 1.day) { "cached_wendel_#{id}_test" }
render json: {message: foo}
end
end
2 changes: 1 addition & 1 deletion app/models/heartbeat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize
end

def memcached_up?
memcached_client = Dalli::Client.new
memcached_client = Dalli::Client.new(ENV["MEMCACHE_SERVERS"])
memcached_client.alive!
true
rescue StandardError
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# config.action_controller.perform_caching = true
config.perform_caching = true
config.action_controller.perform_caching = true
config.cache_store = :dalli_store, nil, { namespace: ENV["APPLICATION"] }
config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"], { namespace: ENV["APPLICATION"] }

# Don't care if the mailer can't send.
# config.action_mailer.raise_delivery_errors = false
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
config.consider_all_requests_local = false
config.perform_caching = true
config.action_controller.perform_caching = true
config.cache_store = :dalli_store, nil, { namespace: ENV["APPLICATION"] }
config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"], { namespace: ENV["APPLICATION"] }

# Attempt to read encrypted secrets from `config/secrets.yml.enc`.
# Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
Expand Down
2 changes: 1 addition & 1 deletion config/environments/stage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Disable/enable fragment and page caching in ActionController
config.perform_caching = true
config.action_controller.perform_caching = true
config.cache_store = :dalli_store, nil, { namespace: ENV["APPLICATION"] }
config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"], { namespace: ENV["APPLICATION"] }

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
root to: "index#index"

resources :heartbeat, only: [:index]
resources :index, path: "/", only: [:index]
resources :index, path: "/", only: [:index, :show]

# trigger agents
post "agents/crossref", to: "agents#crossref"
Expand Down
1 change: 0 additions & 1 deletion spec/concerns/cacheable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

describe "when there is a cache hit" do
it "will fetch the value from cache" do
debugger
Rails.cache.fetch("ras/100", expires: 1.day) { { message: "from cache" } }
result = RelatedIdentifier.cached_doi_ra("100")
expect(result).to(eq({message: "from cache"}))
Expand Down

0 comments on commit b5cf621

Please sign in to comment.