Permalink
Browse files

Replace memcached with dalli

dalli is a pure ruby library, so this removes the dependency on the libmemcached C library
  • Loading branch information...
1 parent d3c1879 commit 4c850e97048caab684b8ac81f43ffa745ebb056b @darkhelmet darkhelmet committed Nov 4, 2012
View
@@ -15,7 +15,7 @@ gem 'high_voltage'
gem 'highline'
gem 'jquery-rails'
gem 'mail'
-gem 'memcached'
+gem 'dalli'
gem 'multi_json'
gem 'paul_revere'
gem 'pg'
View
@@ -73,6 +73,7 @@ GEM
cucumber (>= 1.1.8)
nokogiri (>= 1.5.0)
daemons (1.1.9)
+ dalli (2.3.0)
database_cleaner (0.9.1)
delayed_job (3.0.3)
activesupport (~> 3.0)
@@ -128,7 +129,6 @@ GEM
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
- memcached (1.4.6)
method_source (0.8.1)
mime-types (1.19)
multi_json (1.3.7)
@@ -254,6 +254,7 @@ DEPENDENCIES
clearance
cucumber-rails
daemons
+ dalli
database_cleaner
delayed_job
delayed_job_active_record
@@ -270,7 +271,6 @@ DEPENDENCIES
jruby-openssl
launchy
mail
- memcached
multi_json
newrelic-redis
newrelic_rpm
@@ -1,11 +1,11 @@
-require 'memcached'
+require 'dalli'
class V1MarshaledDepedencies
LIMIT = 250
BadRequest = [404, {}, ["Go away"]]
- TooMany = [413, {},
+ TooMany = [413, {},
["Too many gems to resolve, please request less than #{LIMIT}"]]
def data_for(name, ary, cache)
@@ -34,7 +34,7 @@ def data_for(name, ary, cache)
ary
end
- CACHE = Memcached.new("localhost:11211")
+ CACHE = Dalli::Client.new("localhost:11211")
def call(env)
request = Rack::Request.new(env)
@@ -55,14 +55,16 @@ def call(env)
gems.each do |g|
begin
data = cache.get "gem.#{g}"
- ary += Marshal.load(data)
- rescue Memcached::NotFound
- begin
- data_for g, ary, cache
- rescue
- return BadRequest
+ if data
+ ary += Marshal.load(data)
+ else
+ begin
+ data_for g, ary, cache
+ rescue
+ return BadRequest
+ end
end
- rescue Memcached::ServerIsMarkedDead
+ rescue Dalli::RingError
begin
data_for g, ary, nil
rescue
Binary file not shown.
Binary file not shown.

0 comments on commit 4c850e9

Please sign in to comment.