redis-rails和connection_pool的问题

时间:2017-08-24 06:57:54

标签: ruby-on-rails ruby connection-pool redis-rails

如何初始化我的redis_store以建立连接池。我想添加池属性{pool_size:10,pool_timeout:10}我添加了connection_pool gem

Example::Application.config.session_store :redis_store,
                                      servers: { host:      'localhost',
                                                 port:      6379,
                                                 db:        0,
                                                 namespace: 'session'
                                      },
                                      expires_in: 25.hours,

它在服务器启动时出错。如果我添加如下的内容;

Example::Application.config.session_store :redis_store,
                                      servers: { host:      'localhost',
                                                 port:      6379,
                                                 db:        0,
                                                 namespace: 'session'
                                      },
                                      expires_in: 25.hours,
                                      { pool_size: 10, pool_timeout: 10 }

1 个答案:

答案 0 :(得分:1)

在我执行完代码后,我遇到了一个简单的SyntaxError。可能是你的问题,因为正确指定选项应该是:

Example::Application.config.session_store :redis_store,
                                      servers: { host:      'localhost',
                                                 port:      6379,
                                                 db:        0,
                                                 namespace: 'session'
                                      },
                                      expires_in: 25.hours,
                                      pool_size: 10,
                                      pool_timeout: 10