Skip to content

Commit

Permalink
Use invert, not inverse and test (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
djmb committed Aug 16, 2023
1 parent 664678e commit 43ce662
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/solid_cache/cluster/connection_handling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def initialize_shards
@nodes = @shards.to_h { |shard| [ shard, shard ] }
when Hash
@shards = @shard_options.keys
@nodes = @shard_options.inverse
@nodes = @shard_options.invert
end

if @shards.count > 1
Expand Down
16 changes: 16 additions & 0 deletions test/unit/cluster_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,20 @@ class ClusterTest < ActiveSupport::TestCase
assert_equal 1, @primary_cache.read("foo", raw: true).to_i
assert_equal 3, @secondary_cache.read("foo", raw: true).to_i
end

test "cache with node names" do
@namespace = "test-#{SecureRandom.hex}"
primary_cluster = { shards: { primary_shard_one: :node1, primary_shard_two: :node2 } }
secondary_cluster = { shards: { primary_shard_one: :node3, primary_shard_two: :node4 } }

@cache = lookup_store(expires_in: 60, clusters: [ primary_cluster, secondary_cluster ])
@primary_cache = lookup_store(expires_in: 60, cluster: primary_cluster)
@secondary_cache = lookup_store(expires_in: 60, cluster: secondary_cluster)

@cache.write("foo", 1)
sleep 0.1
assert_equal 1, @cache.read("foo")
assert_equal 1, @primary_cache.read("foo")
assert_equal 1, @secondary_cache.read("foo")
end
end

0 comments on commit 43ce662

Please sign in to comment.