Skip to content

Commit

Permalink
ensure the redis cluster is available on the RedisClient object
Browse files Browse the repository at this point in the history
refs AE-1191

Change-Id: I9086994eb096cdcd18f605b96b81136e005905ff
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/362051
Tested-by: Service Cloud Jenkins <[email protected]>
Reviewed-by: Jacob Burroughs <[email protected]>
QA-Review: Aaron Ogata <[email protected]>
Product-Review: Aaron Ogata <[email protected]>
  • Loading branch information
aogata-inst committed Nov 8, 2024
1 parent 3b02fcb commit 8ea85eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion config/initializers/cache_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@
cache_map[cluster] = if last_cluster_cache_config == config
Switchman.config[:cache_map][cluster]
else
Canvas.lookup_cache_store(config, cluster)
store = Canvas.lookup_cache_store(config, cluster)
# The `.client` method is reserved for the actual redis CLIENT command, but we need the RubyClient object
# which is represented by `_client`.`
store.redis._client.ring = cluster
store
end
end

Expand Down
5 changes: 5 additions & 0 deletions gems/canvas_cache/lib/canvas_cache/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def pipelined(_key = nil, **kwargs, &)
# rubocop:enable Style/ArgumentsForwarding
end

module TaggedRing
attr_accessor :ring
end

module Distributed
def initialize(addresses, options = {})
options[:ring] ||= HashRing.new([], options[:replicas], options[:digest])
Expand Down Expand Up @@ -168,6 +172,7 @@ def patch
::Redis.prepend(Redis)
::Redis.prepend(IgnorePipelinedKey)
::RedisClient.prepend(Client)
::RedisClient.prepend(TaggedRing)
::Redis::Cluster::Client.prepend(Cluster)
::RedisClient::Cluster.prepend(IgnorePipelinedKey)
::Redis::Client.prepend(Client)
Expand Down

0 comments on commit 8ea85eb

Please sign in to comment.