index.js
function redisSetCertificate(options, callback) {
    _debug('le-store-redis.redisSetCertificate',
      '\npems:', options.pems);
    var certId = 'cert-' + crypto.createHash('sha256')
      .update(options.pems.cert).digest('hex');
    var cert = _.cloneDeep(options.pems);

    var jsonCert = JSON.stringify(cert);

    async.parallel([
      function(callback) {
        // write the cert to the database
        client.set(certId, jsonCert, callback);
        return client.expire(certId, moduleOptions.certExpiry);
      },
      function(callback) {
        if(options.accountId) {
          // create an accountId to cert index
          return _createIndex('idx-a2c', options.accountId, certId,
            moduleOptions.certExpiry, callback);
        }
        callback();
      },
      function(callback) {
        if(options.email) {
          // create an email to cert index
          return _createIndex('idx-e2c', options.email, certId,
            moduleOptions.certExpiry, callback);
        }
        callback();
      },
      function(callback) {
        if(options.domains) {
          // create a domain to cert index
          return async.each(options.domains, function(domain, callback) {
            _createIndex('idx-d2c', domain, certId,
              moduleOptions.certExpiry, callback);
          }, function(err) {
            callback(err);
          });
        }
        callback();
      }], function(err) {
        if(err) {
          return callback(err);
        }
        callback(null, cert);
    });
  }
function redisSetCertificate(options, callback) {
    _debug('le-store-redis.redisSetCertificate',
      '\npems:', options.pems);
    var certId = 'cert-' + crypto.createHash('sha256')
      .update(options.pems.cert).digest('hex');
    var cert = _.cloneDeep(options.pems);

    var jsonCert = JSON.stringify(cert);

    async.parallel([
      function(callback) {
        // write the cert to the database
        client.set(certId, jsonCert, callback);
        return client.expire(certId, moduleOptions.certExpiry);
      },
      function(callback) {
        if(options.accountId) {
          // create an accountId to cert index
          return _createIndex('idx-a2c', options.accountId, certId,
            moduleOptions.certExpiry, callback);
        }
        callback();
      },
      function(callback) {
        if(options.email) {
          // create an email to cert index
          return _createIndex('idx-e2c', options.email, certId,
            moduleOptions.certExpiry, callback);
        }
        callback();
      },
      function(callback) {
        if(options.domains) {
          // create a domain to cert index
          return async.each(options.domains, function(domain, callback) {
            _createIndex('idx-d2c', domain, certId,
              moduleOptions.certExpiry, callback);
          }, function(err) {
            callback(err);
          });
        }
        callback();
      }], function(err) {
        if(err) {
          return callback(err);
        }
        callback(null, cert);
    });
  }
function redisSetCertificate ( options , callback ) { _debug ( 'le-store-redis.redisSetCertificate' , '\npems:' , options . pems ) ; var certId = 'cert-' + crypto . createHash ( 'sha256' ) . update ( options . pems . cert ) . digest ( 'hex' ) ; var cert = _ . cloneDeep ( options . pems ) ; var jsonCert = JSON . stringify ( cert ) ; async . parallel ( [ function ( callback ) { // write the cert to the database client . set ( certId , jsonCert , callback ) ; return client . expire ( certId , moduleOptions . certExpiry ) ; } , function ( callback ) { if ( options . accountId ) { // create an accountId to cert index return _createIndex ( 'idx-a2c' , options . accountId , certId , moduleOptions . certExpiry , callback ) ; } callback ( ) ; } , function ( callback ) { if ( options . email ) { // create an email to cert index return _createIndex ( 'idx-e2c' , options . email , certId , moduleOptions . certExpiry , callback ) ; } callback ( ) ; } , function ( callback ) { if ( options . domains ) { // create a domain to cert index return async . each ( options . domains , function ( domain , callback ) { _createIndex ( 'idx-d2c' , domain , certId , moduleOptions . certExpiry , callback ) ; } , function ( err ) { callback ( err ) ; } ) ; } callback ( ) ; } ] , function ( err ) { if ( err ) { return callback ( err ) ; } callback ( null , cert ) ; } ) ; }
Stores a certificate in the database.

@param {Object[]} options - options passed to the storage call.
@param {string} options[].domains - domains associated with
certificate.
@param {string} options[].email - email address associated with
certificate.
@param {string} options[].accountId - accound identifier associated with
certificate.
@param {Object[]} options[].pems - The PEM-encoded certificate data to store.
@param {string} options[].pems[].privkey - the private key.
@param {string} options[].pems[].cert - the certificate.
@param {string} options[].pems[].chain - the certificate chain.
@param {Function} callback(err, pems) - called when an error occurs, or
when all the certificate data is successfully written to the database.
Stores a certificate in the database .