function configurePersist(app) {
  
  redisClient = redis.createClient();

  redisClient.on("error", function (err) {
    app.logger.error("Error " + err);
  });
 
  /**
   * register event-listener for commands
   */
  function configureCmds() {
    app.commands.addListener('new', persistModel);
    app.commands.addListener('update', persistModel);
    app.commands.addListener('removed', function(key) {

      redisClient.hdel(COMMANDKEY, key, function(err) {
        
        if(err) {
          app.logger.error('Could not remove Command ' + key);
        } else {
          app.logger.info('Removed Command ' + key);
        }

      });

    });
  }

  /**
   * register event-listener for regions
   */
  function configureRegions() {
    app.regions.addListener('new', persistModel);
    app.regions.addListener('update', persistModel);
    app.regions.addListener('removed', function(key) {

      redisClient.hdel(REGIONKEY, key, function(err) {
        
        if(err) {
          app.logger.error('Could not remove Region ' + key);
      } else {
          app.logger.info('Removed Region ' + key);
        }

      });

    });
  }

  // load commands and regions 
  loadModels(REGIONKEY, app.regions, app, function() {
    loadModels(COMMANDKEY, app.commands, app, function() {
    });
  });
  
  configureRegions();
  configureCmds();

  // housekeeping
  process.on('SIGINT', function() {
    redisClient.quit();
    process.exit();
  });
}
/**
 * Persisting models with redis-server
 * This getting refactored soon!
 */
Persisting models with redis-server
This getting refactored soon!
Persisting models with redis - server This getting refactored soon!
function configurePersist(app) {
  redisClient = redis.createClient();
  redisClient.on("error", function (err) {
    app.logger.error("Error " + err);
  });
  function configureCmds() {
    app.commands.addListener('new', persistModel);
    app.commands.addListener('update', persistModel);
    app.commands.addListener('removed', function(key) {
      redisClient.hdel(COMMANDKEY, key, function(err) {
        if(err) {
          app.logger.error('Could not remove Command ' + key);
        } else {
          app.logger.info('Removed Command ' + key);
        }
      });
    });
  }
  function configureRegions() {
    app.regions.addListener('new', persistModel);
    app.regions.addListener('update', persistModel);
    app.regions.addListener('removed', function(key) {
      redisClient.hdel(REGIONKEY, key, function(err) {
        if(err) {
          app.logger.error('Could not remove Region ' + key);
      } else {
          app.logger.info('Removed Region ' + key);
        }
      });
    });
  }
  loadModels(REGIONKEY, app.regions, app, function() {
    loadModels(COMMANDKEY, app.commands, app, function() {
    });
  });
  configureRegions();
  configureCmds();
  process.on('SIGINT', function() {
    redisClient.quit();
    process.exit();
  });
}
function configurePersist ( app ) { redisClient = redis . createClient ( ) ; redisClient . on ( "error" , function ( err ) { app . logger . error ( "Error " + err ) ; } ) ; function configureCmds ( ) { app . commands . addListener ( 'new' , persistModel ) ; app . commands . addListener ( 'update' , persistModel ) ; app . commands . addListener ( 'removed' , function ( key ) { redisClient . hdel ( COMMANDKEY , key , function ( err ) { if ( err ) { app . logger . error ( 'Could not remove Command ' + key ) ; } else { app . logger . info ( 'Removed Command ' + key ) ; } } ) ; } ) ; } function configureRegions ( ) { app . regions . addListener ( 'new' , persistModel ) ; app . regions . addListener ( 'update' , persistModel ) ; app . regions . addListener ( 'removed' , function ( key ) { redisClient . hdel ( REGIONKEY , key , function ( err ) { if ( err ) { app . logger . error ( 'Could not remove Region ' + key ) ; } else { app . logger . info ( 'Removed Region ' + key ) ; } } ) ; } ) ; } loadModels ( REGIONKEY , app . regions , app , function ( ) { loadModels ( COMMANDKEY , app . commands , app , function ( ) { } ) ; } ) ; configureRegions ( ) ; configureCmds ( ) ; process . on ( 'SIGINT' , function ( ) { redisClient . quit ( ) ; process . exit ( ) ; } ) ; }
Persisting models with redis-server
 This getting refactored soon!
Persisting models with redis - server This getting refactored soon!
/**
   * register event-listener for commands
   */ /**
   * register event-listener for regions
   */ // load commands and regions  // housekeeping