title: Redis connection in multi-threaded environment (Unicorn)
body: <p>I've been struggling with this error for quite some time:</p>
  
  <pre><code>Redis::ProtocolError: Got 'i' as initial reply byte. 
  If you're running in a multi-threaded environment, make sure you pass the :thread_safe
  option when initializing the connection. If you're in a forking environment, such as 
  Unicorn, you need to connect to Redis after forking.
  </code></pre>
  
  <p>It happens intermittently in apps that use Unicorn and Redis. From this <a href="https://github.com/redis/redis-rb/pull/188" rel="nofollow">redis-rb Github issue</a> it looks the <code>:thread_safe</code> option is now enabled by default. I am using <code>redis 2.2.2</code> because <code>redis 3.0.1</code> is not compatible with the latest version of <code>resque</code>.</p>
  
  <p>In my Unicorn config I'm using <code>Redis.current.quit</code> after the fork.</p>
  
  <p>I'm also connecting to Redis with a gem called <code>ruote-redis</code> which is a storage implementation for the workflow engine Ruote.</p>
  
  <p>How can I ensure that all of my Redis connections are stable and that I don't get this error anymore which is disrupting to the normal use of our app?</p>