A platform for community discussion. Free, open, simple.
FIX: support Arrays with Marshal dump in distributed cache
Sama35f2984e953
diff --git a/lib/distributed_cache.rb b/lib/distributed_cache.rbindex 2c454526dbf..203bb2ae842 100644--- a/lib/distributed_cache.rb+++ b/lib/distributed_cache.rb@@ -74,7 +74,7 @@ class DistributedCachedef set(hash, key, value)# special support for set- marshal = (Set === value || Hash === value)+ marshal = (Set === value || Hash === value || Array === value)value = Base64.encode64(Marshal.dump(value)) if marshalpublish(hash, op: :set, key: key, value: value, marshalled: marshal)enddiff --git a/spec/components/distributed_cache_spec.rb b/spec/components/distributed_cache_spec.rbindex a1b442edf17..4ff420c96e4 100644--- a/spec/components/distributed_cache_spec.rb+++ b/spec/components/distributed_cache_spec.rb@@ -29,6 +29,20 @@ describe DistributedCache docache(cache_name)end+ it 'supports arrays with hashes' do++ c1 = cache("test1")+ c2 = cache("test1")++ c1["test"] = [{ test: :test }]++ wait_for do+ c2["test"] == [{ test: :test }]+ end++ expect(c2[:test]).to eq([{ test: :test }])+ end+it 'allows us to store Set' doc1 = cache("test1")c2 = cache("test1")