Disable Dalli compression on the protocal level
We were disabling in the write level but since Dalli 3 the protocol is compressing by default and ignoring the option at write level.
This commit is contained in:
parent
370ef3d5b6
commit
6a1ee787a0
|
@ -121,7 +121,9 @@ module ActiveSupport
|
|||
@data = addresses.first
|
||||
else
|
||||
mem_cache_options = options.dup
|
||||
UNIVERSAL_OPTIONS.each { |name| mem_cache_options.delete(name) }
|
||||
# The value "compress: false" prevents duplicate compression within Dalli.
|
||||
mem_cache_options[:compress] = false
|
||||
(UNIVERSAL_OPTIONS - %i(compress)).each { |name| mem_cache_options.delete(name) }
|
||||
@data = self.class.build_mem_cache(*(addresses + [mem_cache_options]))
|
||||
end
|
||||
end
|
||||
|
@ -236,8 +238,9 @@ module ActiveSupport
|
|||
expires_in += 5.minutes
|
||||
end
|
||||
rescue_error_with false do
|
||||
# The value "compress: false" prevents duplicate compression within Dalli.
|
||||
@data.with { |c| c.send(method, key, payload, expires_in, **options, compress: false) }
|
||||
# Don't pass compress option to Dalli since we are already dealing with compression.
|
||||
options.delete(:compress)
|
||||
@data.with { |c| c.send(method, key, payload, expires_in, **options) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class CacheStoreSettingTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_mem_cache_fragment_cache_store
|
||||
assert_called_with(Dalli::Client, :new, [%w[localhost], {}]) do
|
||||
assert_called_with(Dalli::Client, :new, [%w[localhost], { compress: false }]) do
|
||||
store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost"
|
||||
assert_kind_of(ActiveSupport::Cache::MemCacheStore, store)
|
||||
end
|
||||
|
@ -52,14 +52,14 @@ class CacheStoreSettingTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_mem_cache_fragment_cache_store_with_multiple_servers
|
||||
assert_called_with(Dalli::Client, :new, [%w[localhost 192.168.1.1], {}]) do
|
||||
assert_called_with(Dalli::Client, :new, [%w[localhost 192.168.1.1], { compress: false }]) do
|
||||
store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost", "192.168.1.1"
|
||||
assert_kind_of(ActiveSupport::Cache::MemCacheStore, store)
|
||||
end
|
||||
end
|
||||
|
||||
def test_mem_cache_fragment_cache_store_with_options
|
||||
assert_called_with(Dalli::Client, :new, [%w[localhost 192.168.1.1], { timeout: 10 }]) do
|
||||
assert_called_with(Dalli::Client, :new, [%w[localhost 192.168.1.1], { timeout: 10, compress: false }]) do
|
||||
store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost", "192.168.1.1", namespace: "foo", timeout: 10
|
||||
assert_kind_of(ActiveSupport::Cache::MemCacheStore, store)
|
||||
assert_equal "foo", store.options[:namespace]
|
||||
|
|
Loading…
Reference in New Issue