From 4ae6399262f50a9b154c033a22fbd84762c42cc0 Mon Sep 17 00:00:00 2001 From: Naveen Date: Thu, 6 Jul 2023 19:58:44 +0530 Subject: [PATCH] (fix): Fixed CROSSSLOT keys issue when using redis cluster --- lib/split/redis_interface.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/split/redis_interface.rb b/lib/split/redis_interface.rb index 5307428a..9f6f322f 100644 --- a/lib/split/redis_interface.rb +++ b/lib/split/redis_interface.rb @@ -11,6 +11,7 @@ def persist_list(list_name, list_values) if list_values.length > 0 redis.multi do |multi| tmp_list = "#{list_name}_tmp" + tmp_list += redis_namespace_used? ? "{#{Split.redis.namespace}:#{list_name}}" : "{#{list_name}}" multi.rpush(tmp_list, list_values) multi.rename(tmp_list, list_name) end @@ -27,5 +28,9 @@ def add_to_set(set_name, value) private attr_accessor :redis + + def redis_namespace_used? + Redis.const_defined?("Namespace") && Split.redis.is_a?(Redis::Namespace) + end end end