Drop memcached and use dalli as the memcache client
This commit is contained in:
parent
42fa563e01
commit
255b0b9425
7 changed files with 10 additions and 40 deletions
5
Gemfile
5
Gemfile
|
@ -77,8 +77,9 @@ gem 'SystemTimer', '>= 1.1.3', :require => 'system_timer', :platforms => :ruby_1
|
||||||
# Load httpclient for SOAP support for Quova GeoIP queries
|
# Load httpclient for SOAP support for Quova GeoIP queries
|
||||||
gem 'httpclient'
|
gem 'httpclient'
|
||||||
|
|
||||||
# Load memcache in case we are using it
|
# Load memcache client in case we are using it
|
||||||
gem 'memcached', '>= 1.4.1'
|
gem 'dalli'
|
||||||
|
gem 'kgio'
|
||||||
|
|
||||||
# Gems useful for development
|
# Gems useful for development
|
||||||
group :development do
|
group :development do
|
||||||
|
|
|
@ -45,6 +45,7 @@ GEM
|
||||||
coffee-script-source (1.6.3)
|
coffee-script-source (1.6.3)
|
||||||
composite_primary_keys (6.0.0)
|
composite_primary_keys (6.0.0)
|
||||||
activerecord (>= 4.0.0)
|
activerecord (>= 4.0.0)
|
||||||
|
dalli (2.6.4)
|
||||||
deadlock_retry (1.2.0)
|
deadlock_retry (1.2.0)
|
||||||
dynamic_form (1.1.4)
|
dynamic_form (1.1.4)
|
||||||
ejs (1.1.1)
|
ejs (1.1.1)
|
||||||
|
@ -70,11 +71,11 @@ GEM
|
||||||
jsonify (< 0.4.0)
|
jsonify (< 0.4.0)
|
||||||
jwt (0.1.8)
|
jwt (0.1.8)
|
||||||
multi_json (>= 1.5)
|
multi_json (>= 1.5)
|
||||||
|
kgio (2.8.1)
|
||||||
libxml-ruby (2.7.0)
|
libxml-ruby (2.7.0)
|
||||||
mail (2.5.4)
|
mail (2.5.4)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
memcached (1.7.0)
|
|
||||||
mime-types (1.25)
|
mime-types (1.25)
|
||||||
mini_portile (0.5.1)
|
mini_portile (0.5.1)
|
||||||
minitest (4.7.5)
|
minitest (4.7.5)
|
||||||
|
@ -176,6 +177,7 @@ DEPENDENCIES
|
||||||
bigdecimal (~> 1.1.0)
|
bigdecimal (~> 1.1.0)
|
||||||
coffee-rails (~> 4.0.0)
|
coffee-rails (~> 4.0.0)
|
||||||
composite_primary_keys (>= 6.0.0)
|
composite_primary_keys (>= 6.0.0)
|
||||||
|
dalli
|
||||||
deadlock_retry (>= 1.2.0)
|
deadlock_retry (>= 1.2.0)
|
||||||
dynamic_form
|
dynamic_form
|
||||||
ejs
|
ejs
|
||||||
|
@ -186,8 +188,8 @@ DEPENDENCIES
|
||||||
jquery-rails
|
jquery-rails
|
||||||
json
|
json
|
||||||
jsonify-rails
|
jsonify-rails
|
||||||
|
kgio
|
||||||
libxml-ruby (>= 2.0.5)
|
libxml-ruby (>= 2.0.5)
|
||||||
memcached (>= 1.4.1)
|
|
||||||
minitest (~> 4.7.0)
|
minitest (~> 4.7.0)
|
||||||
open_id_authentication (>= 1.1.0)
|
open_id_authentication (>= 1.1.0)
|
||||||
openstreetmap-i18n-js (>= 3.0.0.rc5.2)
|
openstreetmap-i18n-js (>= 3.0.0.rc5.2)
|
||||||
|
|
|
@ -58,7 +58,7 @@ OpenStreetMap::Application.configure do
|
||||||
|
|
||||||
# Use a different cache store in production.
|
# Use a different cache store in production.
|
||||||
if defined?(MEMCACHE_SERVERS)
|
if defined?(MEMCACHE_SERVERS)
|
||||||
config.cache_store = :mem_cache_store, MemCache.new(:namespace => "rails:cache", :no_block => true, :buffer_requests => true, :noreply => true)
|
config.cache_store = :mem_cache_store, MEMCACHE_SERVERS, { :namespace => "rails:cache" }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
if defined?(MEMCACHE_SERVERS)
|
if defined?(MEMCACHE_SERVERS)
|
||||||
require "openid/store/memcache"
|
require "openid/store/memcache"
|
||||||
|
|
||||||
OpenIdAuthentication.store = OpenID::Store::Memcache.new(MemCache.new(:namespace => "rails", :string_return_types => true))
|
OpenIdAuthentication.store = OpenID::Store::Memcache.new(Dalli::Client.new(MEMCACHE_SERVERS, :namespace => "rails"))
|
||||||
else
|
else
|
||||||
OpenIdAuthentication.store = :file
|
OpenIdAuthentication.store = :file
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
# Be sure to restart your server when you modify this file.
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
if defined?(MEMCACHE_SERVERS)
|
if defined?(MEMCACHE_SERVERS)
|
||||||
cache = MemCache.new(:namespace => "rails:session", :string_return_types => true)
|
OpenStreetMap::Application.config.session_store :mem_cache_store, :memcache_servers => MEMCACHE_SERVERS, :namespace => "rails:session", :key => "_osm_session"
|
||||||
|
|
||||||
OpenStreetMap::Application.config.session_store :mem_cache_store, :cache => cache, :key => "_osm_session"
|
|
||||||
else
|
else
|
||||||
OpenStreetMap::Application.config.session_store :cache_store, :key => '_osm_session'
|
OpenStreetMap::Application.config.session_store :cache_store, :key => '_osm_session'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
class MemCache < Memcached::Rails
|
|
||||||
DEFAULT_OPTIONS = Memcached::DEFAULTS.merge(Memcached::Rails::DEFAULTS)
|
|
||||||
|
|
||||||
MemCacheError = Memcached::Error
|
|
||||||
|
|
||||||
@@connections = []
|
|
||||||
|
|
||||||
def initialize(options = {})
|
|
||||||
options.reverse_merge! :namespace_separator => ":"
|
|
||||||
|
|
||||||
super(MEMCACHE_SERVERS, options)
|
|
||||||
|
|
||||||
@@connections.push(self)
|
|
||||||
|
|
||||||
ObjectSpace.define_finalizer(self, lambda { |connection|
|
|
||||||
@@connections.remove(connection)
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.connections
|
|
||||||
@@connections
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if defined?(PhusionPassenger)
|
|
||||||
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
|
||||||
if forked
|
|
||||||
MemCache.connections.each { |connection| connection.reset }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Add table
Add a link
Reference in a new issue