title: How should I do a RedisDict in python?
body: <p>I am doing <a href="https://github.com/spiral-project/respire/tree/master/respire/tests/todo" rel="nofollow">a really simple API</a> to test respire a SPORE client generation for python.</p>
  
  <p>In WSGI, what would be the best way to keep data throught the server?</p>
  
  <p>I try to make a RedisDict that way:</p>
  
  <pre><code>import json
  from redis import Redis
  redis = Redis()
  
  class RedisDict:
      """A redis based dict."""
  
      def dict(self):
          TODOS = redis.get('TODOS')
          return json.loads(TODOS)
  
      def keys(self):
          return self.dict().keys()
  
      def __getitem__(self, key):
          return self.dict()[key]
  
      def __setitem__(self, key, value):
          obj = self.dict()
          obj[key] = value
          redis.set('TODOS', json.dumps(obj))
  
      def __delitem__(self, key):
          obj = self.dict()
          del obj[key]
          redis.set('TODOS', json.dumps(obj))
  
  todos = RedisDict()
  </code></pre>
  
  <p>How can I make <code>dict(todos)</code> to return a dict?
  Is that enough in a WSGI environment ?</p>