FEATURE: Add `publish_queue_in_memory` option to distributed cache manager.

FEATURE: Add publish_queue_in_memory option to distributed cache manager.

This is a partial revert of e91d41483a89dbcd3a6ecc3aeef47d353b5c6681. Instead of changing the default behavior of what MessageBus::DistributedCache::Manager#publish should do when it is called on a Readonly redis, this commit introduces an option to change the behavior.

diff --git a/lib/message_bus/distributed_cache.rb b/lib/message_bus/distributed_cache.rb
index 15404d5..92820f0 100644
--- a/lib/message_bus/distributed_cache.rb
+++ b/lib/message_bus/distributed_cache.rb
@@ -16,11 +16,12 @@ module MessageBus
 
       attr_accessor :app_version
 
-      def initialize(message_bus = nil)
+      def initialize(message_bus = nil, publish_queue_in_memory: true)
         @subscribers = []
         @subscribed = false
         @lock = Mutex.new
         @message_bus = message_bus || MessageBus
+        @publish_queue_in_memory = publish_queue_in_memory
       end
 
       def subscribers
@@ -75,7 +76,11 @@ module MessageBus
         message[:origin] = hash.identity
         message[:hash_key] = hash.key
         message[:app_version] = @app_version if @app_version
-        @message_bus.publish(CHANNEL_NAME, message, user_ids: [-1], queue_in_memory: false)
+
+        @message_bus.publish(CHANNEL_NAME, message,
+          user_ids: [-1],
+          queue_in_memory: @publish_queue_in_memory
+        )
       end
 
       def set(hash, key, value)

GitHub sha: 04d2ac08