redis-rb/redis-client

Support for ActiveSupport::Duration in command_builder.rb

Closed this issue · 1 comments

I am not sure, if there is any specific reason causing it to be excluded. I was updating Sidekiq version fro 6.0 to 7.0 and came across this issue.

Sidekiq.redis do |r|
  r.pipelined do |p|
    p.rpush('dummy_key, 'dummy_file_path')
    p.expire('dummy_key', 1.day)
  end
end

# raised this exception
TypeError: Unsupported command argument type: ActiveSupport::Duration

Can you please help me out here with better insights? Much appreciated 👍🏻

This is on purpose to avoid accidental casting. Just tall .to_i on that duration:

Sidekiq.redis do |r|
  r.pipelined do |p|
    p.rpush('dummy_key, 'dummy_file_path')
    p.expire('dummy_key', 1.day.to_i)
  end
end