Skip to content

Commit

Permalink
chore: Replace memcached gem with Dalli
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgns committed May 4, 2024
1 parent c5da8c1 commit bfee340
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
1 change: 1 addition & 0 deletions ditty.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Gem::Specification.new do |spec|

spec.add_development_dependency 'bundler', '>= 1'
spec.add_development_dependency 'dotenv'
spec.add_development_dependency 'dalli'
spec.add_development_dependency 'database_cleaner', '~> 1.0'
spec.add_development_dependency 'factory_bot'
spec.add_development_dependency 'faker'
Expand Down
5 changes: 3 additions & 2 deletions lib/ditty/memcached.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'ditty/services/logger'

Ditty::Services::Logger.info 'Setting up caching'
require 'memcached'
CACHE = Memcached.new(ENV['MEMCACHED_URL'])

require 'dalli'
CACHE = Dalli::Client.new(ENV['MEMCACHED_URL'])
Sequel::Model.plugin :caching, CACHE, ignore_exceptions: true
15 changes: 4 additions & 11 deletions lib/ditty/services/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'dalli'
require 'net/telnet'
require 'memcached'
require 'dalli'

module Ditty
module Services
Expand Down Expand Up @@ -33,9 +33,9 @@ def set(key, obj)

def get(key)
store&.get(key)
rescue Memcached::ServerIsMarkedDead => e
logger.warn "Could not retrieve cache key #{key}: #{e.message}"
nil
# rescue Memcached::ServerIsMarkedDead => e
# logger.warn "Could not retrieve cache key #{key}: #{e.message}"
# nil
end

def clear(key)
Expand Down Expand Up @@ -103,10 +103,3 @@ def logger
end
end
end

module URI
class Memcached < Generic
DEFAULT_PORT = 11211
end
register_scheme 'Memcached', Memcached
end
8 changes: 4 additions & 4 deletions views/partials/notifications.haml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
- if flash[:danger]
.alert.alert-danger.alert-dismissible{ role: "alert" }
.alert.alert-danger.alert-dismissible{ role: 'alert' }
%button.close{ type: 'button', 'aria-label': 'Close', 'data-dismiss': 'alert' }
%span{ 'aria-hidden': 'true' } &times;
%ul.mb-0
- [*flash[:danger]].each do |msg|
%li= msg

- if flash[:warning]
.alert.alert-warning.alert-dismissible{ role: "alert" }
.alert.alert-warning.alert-dismissible{ role: 'alert' }
%button.close{ type: 'button', 'aria-label': 'Close', 'data-dismiss': 'alert' }
%span{ 'aria-hidden': 'true' } &times;
%ul.mb-0
- [*flash[:warning]].each do |msg|
%li= msg

- if flash[:success]
.alert.alert-success.alert-dismissible{ role: "alert" }
.alert.alert-success.alert-dismissible{ role: 'alert' }
%button.close{ type: 'button', 'aria-label': 'Close', 'data-dismiss': 'alert' }
%span{ 'aria-hidden': 'true' } &times;
%ul.mb-0
Expand All @@ -24,7 +24,7 @@


- if flash[:info]
.alert.alert-info.alert-dismissible{ role: "alert" }
.alert.alert-info.alert-dismissible{ role: 'alert' }
%button.close{ type: 'button', 'aria-label': 'Close', 'data-dismiss': 'alert' }
%span{ 'aria-hidden': 'true' } &times;
%ul.mb-0
Expand Down

0 comments on commit bfee340

Please sign in to comment.