lib/cache/AbstractCache.js
function AbstractCache(state, name, options) {
  this.state = state
  this.name = name
  this.options = options
  this._update = this._update.bind(this)

  this._setLock = false
  this._setCallbacks = []

  this._needsRefresh = false
  this.state.on('refreshCache', function (needsRefresh) {
    this._needsRefresh = needsRefresh
  }.bind(this))


  // Build our own `run` instance-method to accurately reflect the fact that
  // `run` is always asynchronous and requires an argument to declare itself
  // as such to our API.
  var protoRun = this.run
  this.run = function(done) {
    if (this.options.run) {
      return this.options.run.apply(this, arguments)
    } else {
      return protoRun.apply(this, arguments)
    }
  }.bind(this)
}
function AbstractCache(state, name, options) {
  this.state = state
  this.name = name
  this.options = options
  this._update = this._update.bind(this)

  this._setLock = false
  this._setCallbacks = []

  this._needsRefresh = false
  this.state.on('refreshCache', function (needsRefresh) {
    this._needsRefresh = needsRefresh
  }.bind(this))


  // Build our own `run` instance-method to accurately reflect the fact that
  // `run` is always asynchronous and requires an argument to declare itself
  // as such to our API.
  var protoRun = this.run
  this.run = function(done) {
    if (this.options.run) {
      return this.options.run.apply(this, arguments)
    } else {
      return protoRun.apply(this, arguments)
    }
  }.bind(this)
}
function AbstractCache ( state , name , options ) { this . state = state this . name = name this . options = options this . _update = this . _update . bind ( this ) this . _setLock = false this . _setCallbacks = [ ] this . _needsRefresh = false this . state . on ( 'refreshCache' , function ( needsRefresh ) { this . _needsRefresh = needsRefresh } . bind ( this ) ) // Build our own `run` instance-method to accurately reflect the fact that // `run` is always asynchronous and requires an argument to declare itself // as such to our API. var protoRun = this . run this . run = function ( done ) { if ( this . options . run ) { return this . options . run . apply ( this , arguments ) } else { return protoRun . apply ( this , arguments ) } } . bind ( this ) }
An abstract class that manages how a method is cached.
@constructor
@param {State} state
@param {string} name The name of the cache key.
@param {Object} options The options for this instance of the cache.
An abstract class that manages how a method is cached .