mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: allow distributed cache to handle Set as value
This commit is contained in:
parent
e3fa27a01c
commit
49ca248186
2 changed files with 33 additions and 2 deletions
|
@ -31,7 +31,7 @@ class DistributedCache
|
|||
hash = current.hash(message.site_id)
|
||||
|
||||
case payload["op"]
|
||||
when "set" then hash[payload["key"]] = payload["value"]
|
||||
when "set" then hash[payload["key"]] = payload["marshalled"] ? Marshal.load(payload["value"]) : payload["value"]
|
||||
when "delete" then hash.delete(payload["key"])
|
||||
when "clear" then hash.clear
|
||||
end
|
||||
|
@ -69,7 +69,10 @@ class DistributedCache
|
|||
end
|
||||
|
||||
def self.set(hash, key, value)
|
||||
publish(hash, { op: :set, key: key, value: value })
|
||||
# special support for set
|
||||
marshal = Set === value
|
||||
value = Marshal.dump(value) if marshal
|
||||
publish(hash, { op: :set, key: key, value: value, marshalled: marshal })
|
||||
end
|
||||
|
||||
def self.delete(hash, key)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue