title: Redis example giving HTTP 400: Bad request error
body: <p>I am trying to cache MySQL queries in my <code>Cherrypy</code> server.</p>
  
  <p>I could not figure out how to solve the error when I was installing <code>pylibmc</code>, so I decided to use <code>Redis-py</code>.</p>
  
  <p>Here I am trying a very simple example.</p>
  
  <pre><code>import redis
  cache = redis.StrictRedis(host='localhost', port=8080, db=0)
         ...
         ...
  cache.set('0', '1') # I also tested with other string keys, but failed with same error
  </code></pre>
  
  <p>and it's throwing the following error!</p>
  
  <pre><code>[05/May/2014:13:11:13] HTTP Traceback (most recent call last):
    File "/Library/Python/2.7/site-packages/cherrypy/_cprequest.py", line 656, in respond
      response.body = self.handler()
    File "/Library/Python/2.7/site-packages/cherrypy/lib/encoding.py", line 188, in __call__
      self.body = self.oldhandler(*args, **kwargs)
    File "/Library/Python/2.7/site-packages/cherrypy/_cpdispatch.py", line 34, in __call__
      return self.callable(*self.args, **self.kwargs)
    File "server.py", line 92, in submit_data
      cache.set(str(idx), '1')#res)
    File "/Library/Python/2.7/site-packages/redis/client.py", line 897, in set
      return self.execute_command('SET', *pieces)
    File "/Library/Python/2.7/site-packages/redis/client.py", line 461, in execute_command
      return self.parse_response(connection, command_name, **options)
    File "/Library/Python/2.7/site-packages/redis/client.py", line 471, in parse_response
      response = connection.read_response()
    File "/Library/Python/2.7/site-packages/redis/connection.py", line 339, in read_response
      response = self._parser.read_response()
    File "/Library/Python/2.7/site-packages/redis/connection.py", line 118, in read_response
      (str(byte), str(response)))
  InvalidResponse: Protocol Error: H, TTP/1.1 400 Bad Request
  </code></pre>
  
  <p>I could not figure out what was wrong, and my website runs without a problem on localhost at port 8080 when I am not using <code>Redis</code>.</p>