新手问题 请问下 sidekiq 的 worker 中要用 client 和 server 连接池对象该怎么取?

jy05874937 · December 29, 2018 · Last by jy05874937 replied at December 29, 2018 · 932 hits

🌱 🌲 🌳 🌴 🌷

搞个全局变量存啊

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
You need to Sign in before reply, if you don't have an account, please Sign up first.