mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 11:01:11 +08:00
FIX: support Arrays with Marshal dump in distributed cache
Theme cache uses arrays here
This commit is contained in:
@ -74,7 +74,7 @@ class DistributedCache
|
|||||||
|
|
||||||
def set(hash, key, value)
|
def set(hash, key, value)
|
||||||
# special support for set
|
# special support for set
|
||||||
marshal = (Set === value || Hash === value)
|
marshal = (Set === value || Hash === value || Array === value)
|
||||||
value = Base64.encode64(Marshal.dump(value)) if marshal
|
value = Base64.encode64(Marshal.dump(value)) if marshal
|
||||||
publish(hash, op: :set, key: key, value: value, marshalled: marshal)
|
publish(hash, op: :set, key: key, value: value, marshalled: marshal)
|
||||||
end
|
end
|
||||||
|
@ -29,6 +29,20 @@ describe DistributedCache do
|
|||||||
cache(cache_name)
|
cache(cache_name)
|
||||||
end
|
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' do
|
it 'allows us to store Set' do
|
||||||
c1 = cache("test1")
|
c1 = cache("test1")
|
||||||
c2 = cache("test1")
|
c2 = cache("test1")
|
||||||
|
Reference in New Issue
Block a user