discourse/lib/distributed_cache.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
573 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'message_bus/distributed_cache'
class DistributedCache < MessageBus::DistributedCache
def initialize(key, manager: nil, namespace: true)
super(
key,
manager: manager,
namespace: namespace,
app_version: Discourse.git_version
)
end
# 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
end