title: How to set up redis for an API using Ruby and Rack?
body: <p>I'm building a simple API using <a href="https://github.com/ruby-grape/grape" rel="nofollow">Grape</a>, Ruby, and Rack (no framework).  I want to use redis to store the data the API is working with. So far, I've defined a <code>Directory</code> class and a <code>DirectoryAPI</code> class using Grape.  The <code>Directory</code> class has methods that return JSON data in the exact same way as the API.</p>
  
  <p>I've never had to set up redis before, so I'm not sure how to do it.  What I'm looking to accomplish is:</p>
  
  <ul>
  <li><p>Do a mass insert to redis when I run <code>rackup</code>, so that there is pre-populated data.  The pre-populated data would come from using my <code>Directory</code> class.</p></li>
  <li><p>Have my GET routes return a hash stored in redis</p></li>
  <li><p>Have the POST route for my API add an entry to redis</p></li>
  </ul>
  
  <p>How do I configure redis to run and populate when I run <code>rackup</code>? Should I do it in my <code>config.ru</code> file somehow and define a new class for redis? How would I get the API class to interact with redis?</p>