lib/runner.js
function load(source) {
  var redis
    , method
    , script
    , name
    , digest;

  digest = sha1hex(source);
  if(this._cache[digest]) {
    return {script: this._cache[digest], sha: digest};
  }

  name = 'f_' + digest;

  method = util.format(
    'var method = function %s(KEYS, ARGS, cb) {%s}', name, source);

  // declare the method
  try {
    script = vm.createScript(method, name);
  }catch(e) {
    return process.send(
      {
        err: true,
        data: 'error compiling script (new function): user_script: '
          + e.message});
  }

  // cache the method by digest
  this._cache[digest] = script;
  log.debug('script load: %s', digest);
  return {sha: digest, script: script};
}
function load(source) {
  var redis
    , method
    , script
    , name
    , digest;

  digest = sha1hex(source);
  if(this._cache[digest]) {
    return {script: this._cache[digest], sha: digest};
  }

  name = 'f_' + digest;

  method = util.format(
    'var method = function %s(KEYS, ARGS, cb) {%s}', name, source);

  // declare the method
  try {
    script = vm.createScript(method, name);
  }catch(e) {
    return process.send(
      {
        err: true,
        data: 'error compiling script (new function): user_script: '
          + e.message});
  }

  // cache the method by digest
  this._cache[digest] = script;
  log.debug('script load: %s', digest);
  return {sha: digest, script: script};
}
function load ( source ) { var redis , method , script , name , digest ; digest = sha1hex ( source ) ; if ( this . _cache [ digest ] ) { return { script : this . _cache [ digest ] , sha : digest } ; } name = 'f_' + digest ; method = util . format ( 'var method = function %s(KEYS, ARGS, cb) {%s}' , name , source ) ; // declare the method try { script = vm . createScript ( method , name ) ; } catch ( e ) { return process . send ( { err : true , data : 'error compiling script (new function): user_script: ' + e . message } ) ; } // cache the method by digest this . _cache [ digest ] = script ; log . debug ( 'script load: %s' , digest ) ; return { sha : digest , script : script } ; }
Compile a script, generate a digest and add it to the cache.
Compile a script generate a digest and add it to the cache .