FEATURE: add setting to bypass sending redis CLIENT commands

FEATURE: add setting to bypass sending redis CLIENT commands

Some cloud providers (Google Memorystore) do not support any CLIENT commands

By setting :id to nil in the redis config hash we can avoid these commands.

This adds a special global setting GCE users can enable:
DISCOURSE_REDIS_SKIP_CLIENT_COMMANDS = true

diff --git a/app/models/global_setting.rb b/app/models/global_setting.rb
index c81430d..67320ee 100644
--- a/app/models/global_setting.rb
+++ b/app/models/global_setting.rb
@@ -152,6 +152,7 @@ class GlobalSetting
         c[:password] = redis_password if redis_password.present?
         c[:db] = redis_db if redis_db != 0
         c[:db] = 1 if Rails.env == "test"
+        c[:id] = nil if redis_skip_client_commands
 
         c.freeze
       end
diff --git a/config/discourse_defaults.conf b/config/discourse_defaults.conf
index 2957af9..1b5fba6 100644
--- a/config/discourse_defaults.conf
+++ b/config/discourse_defaults.conf
@@ -117,6 +117,8 @@ redis_db = 0
 # redis password
 redis_password =
 
+# skip configuring client id for cloud providers who support no client commands
+redis_skip_client_commands = false
 
 # enable Cross-origin Resource Sharing (CORS) directly at the application level
 enable_cors = false

GitHub
sha: 8b7a2d1c

1 Like

see alos: