index.js
function _createIndex(indexName, indexData, value, ex, cb) {
    var callback = cb;
    var expiry = ex;
    if(!callback) {
      expiry = null;
      callback = ex;
    }

    // generate the index value
    var index = indexName + '-' +
      crypto.createHash('sha256').update(indexData).digest('hex');

    client.set(index, value, function(err, reply) {
      if(err) {
        return callback(err);
      }
      if(expiry) {
        return client.expire(index, expiry, function(err) {
          callback(err, reply);
        });
      }
      callback(err, reply);
    });
  }
function _createIndex(indexName, indexData, value, ex, cb) {
    var callback = cb;
    var expiry = ex;
    if(!callback) {
      expiry = null;
      callback = ex;
    }

    // generate the index value
    var index = indexName + '-' +
      crypto.createHash('sha256').update(indexData).digest('hex');

    client.set(index, value, function(err, reply) {
      if(err) {
        return callback(err);
      }
      if(expiry) {
        return client.expire(index, expiry, function(err) {
          callback(err, reply);
        });
      }
      callback(err, reply);
    });
  }
function _createIndex ( indexName , indexData , value , ex , cb ) { var callback = cb ; var expiry = ex ; if ( ! callback ) { expiry = null ; callback = ex ; } // generate the index value var index = indexName + '-' + crypto . createHash ( 'sha256' ) . update ( indexData ) . digest ( 'hex' ) ; client . set ( index , value , function ( err , reply ) { if ( err ) { return callback ( err ) ; } if ( expiry ) { return client . expire ( index , expiry , function ( err ) { callback ( err , reply ) ; } ) ; } callback ( err , reply ) ; } ) ; }
utility function to create a Redis-based index to a particular value
utility function to create a Redis - based index to a particular value