2017-08-01 15:11:48 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-15 14:01:25 -05:00
|
|
|
require 'message_bus/distributed_cache'
|
2014-11-11 16:43:41 -06:00
|
|
|
|
2018-10-15 14:01:25 -05:00
|
|
|
class DistributedCache < MessageBus::DistributedCache
|
2017-10-20 03:39:31 -05:00
|
|
|
def initialize(key, manager: nil, namespace: true)
|
2018-10-15 14:01:25 -05:00
|
|
|
super(
|
|
|
|
key,
|
|
|
|
manager: manager,
|
|
|
|
namespace: namespace,
|
|
|
|
app_version: Discourse.git_version
|
|
|
|
)
|
2014-11-11 16:43:41 -06:00
|
|
|
end
|
2021-06-02 02:46:48 -05:00
|
|
|
|
|
|
|
# Defer setting of the key in the cache for performance critical path to avoid
|
|
|
|
# waiting on MessageBus to publish the message which involves writing to Redis.
|
|
|
|
def defer_set(k, v)
|
|
|
|
Scheduler::Defer.later("#{@key}_set") do
|
|
|
|
self[k] = v
|
|
|
|
end
|
|
|
|
end
|
2014-11-11 16:43:41 -06:00
|
|
|
end
|