lib/message_bus/backends/redis.rb in message_bus-3.3.5 vs lib/message_bus/backends/redis.rb in message_bus-3.3.6

- old
+ new

@@ -1,12 +1,10 @@ # frozen_string_literal: true require 'redis' require 'digest' -require "message_bus/backends/base" - module MessageBus module Backends # The Redis backend stores published messages in Redis sorted sets (using # ZADD, where the score is the message ID), one for each channel (where # the full message is stored), and also in a global backlog as a simple @@ -102,11 +100,11 @@ local global_backlog_key = KEYS[4] local redis_channel_name = KEYS[5] local global_id = redis.call("INCR", global_id_key) local backlog_id = redis.call("INCR", backlog_id_key) - local payload = string.format("%i|%i|%s", global_id, backlog_id, start_payload) - local global_backlog_message = string.format("%i|%s", backlog_id, channel) + local payload = table.concat({ global_id, backlog_id, start_payload }, "|") + local global_backlog_message = table.concat({ backlog_id, channel }, "|") redis.call("ZADD", backlog_key, backlog_id, payload) redis.call("EXPIRE", backlog_key, max_backlog_age) redis.call("ZADD", global_backlog_key, global_id, global_backlog_message) redis.call("EXPIRE", global_backlog_key, max_backlog_age)