搞个全局变量存啊
ps: 文体两开花?
https://github.com/mperham/sidekiq/wiki/Advanced-Options
class HardWorker include Sidekiq::Worker MEMCACHED_POOL = ConnectionPool.new(size: 10, timeout: 3) { Dalli::Client.new } def perform(args) MEMCACHED_POOL.with do |dalli| dalli.set('foo', 'bar') end end end
多谢啦