2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-07 12:02:53 +08:00

FIX: Handle nil values in DistributedCache#defer_get_set (#15978)

Themes often cache `nil` values in a DistributedCache. This bug meant that we were re-calculating some values on every request, AND triggering message-bus publishing on every request.

This fix should provide a significant performance improvement for busy sites.
This commit is contained in:
David Taylor 2022-02-17 14:52:14 +00:00 committed by GitHub
parent df96374700
commit ffcd2e9faf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View file

@ -21,7 +21,7 @@ class DistributedCache < MessageBus::DistributedCache
end
def defer_get_set(k, &block)
return self[k] if self[k]
return self[k] if hash.key? k
value = block.call
self.defer_set(k, value)
value