mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: Cache keys should be strings (#25791)
* FIX: Cache keys should be strings Otherwise, there are subtle bugs that don't show up with a single process.
This commit is contained in:
parent
428db40deb
commit
13291dc5ef
|
@ -936,7 +936,7 @@ class Category < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def url
|
||||
@@url_cache.defer_get_set(self.id) do
|
||||
@@url_cache.defer_get_set(self.id.to_s) do
|
||||
"#{Discourse.base_path}/c/#{slug_path.join("/")}/#{self.id}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ class DistributedCache < MessageBus::DistributedCache
|
|||
end
|
||||
|
||||
def defer_get_set(k, &block)
|
||||
raise TypeError if !Rails.env.production? && !k.is_a?(String)
|
||||
|
||||
return self[k] if hash.key? k
|
||||
value = block.call
|
||||
self.defer_set(k, value)
|
||||
|
|
Loading…
Reference in New Issue
Block a user