[英]How do I use an existing Redis connection in Vanity?
I have a Redis add-on in Heroku that only allows 10 connections. 我在Heroku中有一个Redis加载项,仅允许10个连接。 My app already uses Redis with
$redis
. 我的应用程序已将Redis与
$redis
。 I have Unicorn with 3 workers and 2 dynos, which is 6 connections. 我有3个工人和2个dynos的独角兽,这是6个连接。 Vanity connects by itself which is another 6 connections.
虚荣本身连接,这是另外6个连接。 That is 12 connections which is over the limit of 10. How do I use the existing
$redis
connection for Vanity so Vanity and my app share the connection? 那是12个连接,超过了10个的限制。如何为Vanity使用现有的
$redis
连接,以便Vanity和我的应用共享该连接?
I saw this deprecated method, but when I try it, it gives an error and stack trace. 我看到了这个不赞成使用的方法,但是当我尝试使用它时,它给出了错误和堆栈跟踪。 It was probably for an old version of Redis client.
这可能是针对Redis客户端的旧版本。
http://rdoc.info/gems/vanity/Vanity/Playground#redis%3D-instance_method http://rdoc.info/gems/vanity/Vanity/Playground#redis%3D-instance_method
I use establish_connection
in my Unicorn.rb file to connect, and pass it the connection string. 我用
establish_connection
在我Unicorn.rb文件连接,并通过它的连接字符串。 I would like to set the connection or Redis client object directly. 我想直接设置连接或Redis客户端对象。
http://rdoc.info/gems/vanity/Vanity/Playground#establish_connection-instance_method http://rdoc.info/gems/vanity/Vanity/Playground#establish_connection-instance_method
Ruby 2.0.0, Rails 4.0.3, Vanity 1.9.0. Ruby 2.0.0,Rails 4.0.3,Vanity 1.9.0。
You can use the Vanity Playground
object programmatically and pass in a Redis adapter with an existing redis
instance. 您可以使用名利场
Playground
编程对象,并在Redis的适配器,通过与现有redis
实例。
Vanity.playground.establish_connection { :adapter => :redis, :redis => $redis }
This is specified in the vanity configuration guide . 这在虚荣配置指南中指定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.