0

I have a Redis add-on in Heroku that only allows 10 connections. My app already uses Redis with $redis. I have Unicorn with 3 workers and 2 dynos, which is 6 connections. Vanity connects by itself which is another 6 connections. 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?

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.

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. I would like to set the connection or Redis client object directly.

http://rdoc.info/gems/vanity/Vanity/Playground#establish_connection-instance_method

Ruby 2.0.0, Rails 4.0.3, Vanity 1.9.0.

4

1 回答 1

1

您可以通过编程方式使用 VanityPlayground对象,并通过现有redis实例传入 Redis 适配器。

Vanity.playground.establish_connection { :adapter => :redis, :redis => $redis }

这在虚荣配置指南中指定。

于 2014-03-20T18:00:00.520 回答