如何將連接池添加到我的Redis設置?如何爲Redis-As-Rails-Cache(使用Redis作爲rails緩存)實現連接池Rails 4.1?
由於某種原因,我似乎無法找到關於此的任何信息。我使用的設置,像這樣的Redis(3.2.0): (你可以假設resque_uri和cache_uri被解析這款C超前)
爲resque:
$REDIS_BACKGROUND_JOB = Redis.new(:host => resque_uri.host,
:port => resque_uri.port,
:password => resque_uri.password)
在初始化序列後我們做
Resque.redis = $REDIS_BACKGROUND_JOB
我們有不同的內存,連接數限制和驅逐政策Redis的第二實例,對Rails的緩存
$REDIS_CACHE = Redis.new(:host => cache_uri.host,
:port => cache_uri.port,
:password => cache_uri.password)
UPDATE 2017-02-16 @ 20-17EST:我使用redis-rails(5.0.1)運行兩個redis實例,一個用於resque(1.25.2),另一個用於緩存層。我已經更新了上面的設置示例。我懷疑在初始化時配置錯了,或者有一個基本的設置不匹配。
UPDATE 2017年2月16日@ 21-37EST:
environments/development.rb
有
config.cache_store = :redis_store, 'redis://localhost:6379/1/cache_store'
儘管我發現了一些示例,告訴我如何使用ConnectionPool.new,但我不確定如何使用以下語法在config/application.rb中配置將其掛接到Rails緩存:'''config。 cache_store =:redis_store,「redis:// localhost:6379/0/cache」''' –
也想在這裏添加一個後續操作,我無法獲得有關Resque的連接池工作情況;它在Resque代碼中出錯。 (但是在嘗試實例化一個基本的Redis.new對象時,我已經能夠獲得一個基本的ConnectionPool,它使用'''gem'connection_pool''''。但是,你會在'''config/application.rb' ''Rails'緩存存儲由'''config配置。cache_store''',我不知道如何添加連接池) –
http://stackoverflow.com/questions/28113940/what-is-the-best-way-to-use-redis-in-a -multi-threaded-rails-environment-puma – Sooraj