title: Should I create a new Redis client for each connection?
body: <p>I'm looking at this code snippet:</p>
  
  <pre><code>var addSnippet = function( req, res ) {
    getPostParams( req, function( obj ) {
        var r = redis.createClient();
  
        r.stream.on( 'connect', function() {
          r.incr( 'nextid' , function( err, id ) {
            r.set( 'snippet:'+id, JSON.stringify( obj ), function() {
              var msg = 'The snippet has been saved at &lt;a href="/'+id+'"&gt;'+req.headers.host+'/'+id+'&lt;/a&gt;';
              res.respond( msg );
            } );
          } );
        } );
      });
  };
  </code></pre>
  
  <p>It's from here: <a href="http://howtonode.org/node-redis-fun" rel="nofollow">http://howtonode.org/node-redis-fun</a>.</p>
  
  <p>I don't quite understand what's going on. From example, I figured that the Redis client is a some kind of interface between the database and the programmer, but now it seems that they are creating a new client for each code submit (the app they are building in the tutorial is accepts code snippet submits and stores them in a database)!</p>
  
  <p>Also, where are Redis databases stored? In the same directory as the script? How to I change that?</p>
  
  <p>I'm using Redis with Node.js.</p>