PERF: Defer setting of distributed cache in more spots.

See follow up commit for rational.

Follow-up to 8cfe203383367cc7a3cf31b3c3960b7b7aac92ef
This commit is contained in:
Alan Guo Xiang Tan
2021-06-03 14:02:40 +08:00
parent cd9941e0ca
commit a8667b5454
6 changed files with 16 additions and 18 deletions

View File

@ -19,4 +19,11 @@ class DistributedCache < MessageBus::DistributedCache
self[k] = v
end
end
def defer_get_set(k, &block)
return self[k] if self[k]
value = block.call
self.defer_set(k, value)
value
end
end