lib/database.js
function Database(store, opts) {
  opts = opts || {};

  // the store that holds this database
  this._store = store;

  // do not coerce values to strings
  this.raw = opts.raw !== undefined ? opts.raw : true;

  // pattern matcher
  this.pattern = opts.pattern || new Pattern();

  this.options = opts;

  // set up initial state
  this.flushdb();

  if(store) {
    // proxy via the store so the server
    // can get statistics across all databases
    this.on('expired', function onExpired(key) {
      store.emit('expired', key);
    })

    this.on('hit', function onHit(key) {
      store.emit('hit', key);
    })

    this.on('miss', function onMiss(key) {
      store.emit('miss', key);
    })
  }
}
function Database(store, opts) {
  opts = opts || {};

  // the store that holds this database
  this._store = store;

  // do not coerce values to strings
  this.raw = opts.raw !== undefined ? opts.raw : true;

  // pattern matcher
  this.pattern = opts.pattern || new Pattern();

  this.options = opts;

  // set up initial state
  this.flushdb();

  if(store) {
    // proxy via the store so the server
    // can get statistics across all databases
    this.on('expired', function onExpired(key) {
      store.emit('expired', key);
    })

    this.on('hit', function onHit(key) {
      store.emit('hit', key);
    })

    this.on('miss', function onMiss(key) {
      store.emit('miss', key);
    })
  }
}
function Database ( store , opts ) { opts = opts || { } ; // the store that holds this database this . _store = store ; // do not coerce values to strings this . raw = opts . raw !== undefined ? opts . raw : true ; // pattern matcher this . pattern = opts . pattern || new Pattern ( ) ; this . options = opts ; // set up initial state this . flushdb ( ) ; if ( store ) { // proxy via the store so the server // can get statistics across all databases this . on ( 'expired' , function onExpired ( key ) { store . emit ( 'expired' , key ) ; } ) this . on ( 'hit' , function onHit ( key ) { store . emit ( 'hit' , key ) ; } ) this . on ( 'miss' , function onMiss ( key ) { store . emit ( 'miss' , key ) ; } ) } }
Represents a collection of key value pairs as a database.

This module allows for a request object to be passed as the
last argument to each command. The request object will then be
passed as an argument when emitting on a write event by key.

This allows transactional semantics whereby a connection needs to
know if a watched key has been modified between the multi and exec
commands.

This class does not perform any validation and it is expected that
command and argument validation has already been performed using the
validate module.

This module will not throw errors or emit an error event you must ensure
data integrity before invoking database methods.
Represents a collection of key value pairs as a database .