简体   繁体   中英

How do I use an existing Redis connection in Vanity?

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.

You can use the Vanity Playground object programmatically and pass in a Redis adapter with an existing redis instance.

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

This is specified in the vanity configuration guide .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM