lib/state.js
function ServerState() {

  // server configuration
  this._conf = new Configuration();
  this._conf.once('load', this.onConfigLoad.bind(this));

  // the server bind address information
  // if listen() is never called this is null
  this._addr = null;

  // timestamp for the last save of the rdb file
  this._lastsave = Date.now();

  // server logger
  this._logger = logger();

  // periodic scheduler
  this._scheduler = new Scheduler();

  // collection of connections
  this._conn = [];

  // master pattern matcher
  this._pattern = new Pattern();

  // the store - this is where the data lives
  this._store = new Store(this._conf);

  // ensure we have a database at index 0
  // the SELECT command will lazily create databases
  // on demand
  if(this._store.databases[0] === undefined) {
    this._store.getDatabase(0, {pattern: this._pattern});
  }

  // server statistics
  this._stats = new Stats(this);

  // server information
  this._info = new Info(this);

  // global pubsub state
  this._pubsub = new PubSub(this._stats);

  // slow log storage
  this._slowlog = new SlowLog(this._conf);

  function onSave(time, diff, version, file) {
    this._lastsave = Date.now();
    this.log.notice('db saved to disk: %s seconds (%s)', time, file)
  }
  Persistence.on('save', onSave.bind(this));

  process.on('debug', debug.bind(this));
  process.on('tick', expire.bind(this));
}
function ServerState() {

  // server configuration
  this._conf = new Configuration();
  this._conf.once('load', this.onConfigLoad.bind(this));

  // the server bind address information
  // if listen() is never called this is null
  this._addr = null;

  // timestamp for the last save of the rdb file
  this._lastsave = Date.now();

  // server logger
  this._logger = logger();

  // periodic scheduler
  this._scheduler = new Scheduler();

  // collection of connections
  this._conn = [];

  // master pattern matcher
  this._pattern = new Pattern();

  // the store - this is where the data lives
  this._store = new Store(this._conf);

  // ensure we have a database at index 0
  // the SELECT command will lazily create databases
  // on demand
  if(this._store.databases[0] === undefined) {
    this._store.getDatabase(0, {pattern: this._pattern});
  }

  // server statistics
  this._stats = new Stats(this);

  // server information
  this._info = new Info(this);

  // global pubsub state
  this._pubsub = new PubSub(this._stats);

  // slow log storage
  this._slowlog = new SlowLog(this._conf);

  function onSave(time, diff, version, file) {
    this._lastsave = Date.now();
    this.log.notice('db saved to disk: %s seconds (%s)', time, file)
  }
  Persistence.on('save', onSave.bind(this));

  process.on('debug', debug.bind(this));
  process.on('tick', expire.bind(this));
}
function ServerState ( ) { // server configuration this . _conf = new Configuration ( ) ; this . _conf . once ( 'load' , this . onConfigLoad . bind ( this ) ) ; // the server bind address information // if listen() is never called this is null this . _addr = null ; // timestamp for the last save of the rdb file this . _lastsave = Date . now ( ) ; // server logger this . _logger = logger ( ) ; // periodic scheduler this . _scheduler = new Scheduler ( ) ; // collection of connections this . _conn = [ ] ; // master pattern matcher this . _pattern = new Pattern ( ) ; // the store - this is where the data lives this . _store = new Store ( this . _conf ) ; // ensure we have a database at index 0 // the SELECT command will lazily create databases // on demand if ( this . _store . databases [ 0 ] === undefined ) { this . _store . getDatabase ( 0 , { pattern : this . _pattern } ) ; } // server statistics this . _stats = new Stats ( this ) ; // server information this . _info = new Info ( this ) ; // global pubsub state this . _pubsub = new PubSub ( this . _stats ) ; // slow log storage this . _slowlog = new SlowLog ( this . _conf ) ; function onSave ( time , diff , version , file ) { this . _lastsave = Date . now ( ) ; this . log . notice ( 'db saved to disk: %s seconds (%s)' , time , file ) } Persistence . on ( 'save' , onSave . bind ( this ) ) ; process . on ( 'debug' , debug . bind ( this ) ) ; process . on ( 'tick' , expire . bind ( this ) ) ; }
Encapsulates the state of the server.
Encapsulates the state of the server .