GitHub PullRequestReviewCommentEvent at 2014-01-13 20:48:21
Repository: zcache
Actor: nicks
Payload: {"comment":{"url":"https://api.github.com/repos/Obvious/zcache/pulls/comments/8839865","id":8839865,"diff_hunk":"@@ -0,0 +1,139 @@\n+// Copyright 2014 The Obvious Corporation.\n+\n+/**\n+ * @fileoverview A very simple cache instance for unit testing.\n+ */\n+\n+var Q = require('kew')\n+var util = require('util')\n+var CacheInstance = require('./CacheInstance')\n+\n+/**\n+ * @constructor\n+ * @param {Logger=} logger An optional logger for logging debug information.\n+ */\n+function SimpleCache(logger) {\n+  this.flush()\n+  this._logger = logger\n+  this._failureCount = 0\n+}\n+util.inherits(SimpleCache, CacheInstance)\n+\n+/** @inheritDoc */\n+SimpleCache.prototype.mget = function (keys) {\n+  if (this._failureCount > 0) return this._fakeFail()\n+  this._stats.mget += 1\n+  this._stats.mgetItemCount.push(keys.length)\n+  var self = this\n+  return Q.resolve(keys.map(function (key) {return self._getInternal(key)}))\n+}\n+\n+/** @inheritDoc */\n+SimpleCache.prototype.get = function (key) {\n+  if (this._failureCount > 0) return this._fakeFail()\n+  this._stats.get += 1\n+  return Q.resolve(this._getInternal(key))\n+}\n+\n+/** @inheritDoc */\n+SimpleCache.prototype.del = function (key) {\n+  if (this._failureCount > 0) return this._fakeFail()\n+  if (this._logger) this._logger.fine('SimpleCache - del', key)\n+  this._stats.del += 1\n+  delete this._data[key]\n+  return Q.resolve()\n+}\n+\n+/** @inheritDoc */\n+SimpleCache.prototype.set = function (key, value) {\n+  if (this._failureCount > 0) return this._fakeFail()\n+  if (this._logger) this._logger.fine('SimpleCache - set', key, value)\n+  this._stats.set += 1\n+  this._data[key] = value\n+  return Q.resolve()\n+}\n+\n+/** @inheritDoc */\n+SimpleCache.prototype.mset = function (items) {\n+  if (this._failureCount > 0) return this._fakeFail()\n+  for (var i = 0, l = items.length; i < l; i++) {\n+    var item = items[i]\n+    this.set(item.key, item.value)\n+  }\n+  return Q.resolve()\n+}\n+\n+SimpleCache.prototype.isAvailable = function () {\n+  return true\n+}\n+\n+SimpleCache.prototype.connect = function () {\n+  return\n+}\n+\n+SimpleCache.prototype.disconnect = function () {\n+  return\n+}\n+\n+SimpleCache.prototype.destroy = function () {\n+  return\n+}\n+\n+/**\n+ * Flush all cached data\n+ */\n+SimpleCache.prototype.flush = function () {\n+  this._data = {}\n+  this.resetStats()\n+}\n+\n+/**\n+ * Get stats data\n+ */\n+SimpleCache.prototype.getStats = function () {\n+  return this._stats","path":"lib/SimpleCache.js","position":94,"original_position":94,"commit_id":"a6f189084ce64c0fd75be30b8a277986a92ac61c","original_commit_id":"a6f189084ce64c0fd75be30b8a277986a92ac61c","user":{"login":"nicks","id":278641,"avatar_url":"https://gravatar.com/avatar/257d706ed3fdb2b8dd00aae9019f0207?d=https%3A%2F%2Fidenticons.github.com%2F9ff7284335f66e02b51e8b20975e434f.png&r=x","gravatar_id":"257d706ed3fdb2b8dd00aae9019f0207","url":"https://api.github.com/users/nicks","html_url":"https://github.com/nicks","followers_url":"https://api.github.com/users/nicks/followers","following_url":"https://api.github.com/users/nicks/following{/other_user}","gists_url":"https://api.github.com/users/nicks/gists{/gist_id}","starred_url":"https://api.github.com/users/nicks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicks/subscriptions","organizations_url":"https://api.github.com/users/nicks/orgs","repos_url":"https://api.github.com/users/nicks/repos","events_url":"https://api.github.com/users/nicks/events{/privacy}","received_events_url":"https://api.github.com/users/nicks/received_events","type":"User","site_admin":false},"body":"The superclass method returns a metrics.Timer, so this is not type-safe. It generally seems like a bad idea, from a maintenance perspective, for the test classes to return a very different object type than the real classes.","created_at":"2014-01-13T20:48:21Z","updated_at":"2014-01-13T20:48:21Z","html_url":"https://github.com/Obvious/zcache/pull/21#discussion_r8839865","pull_request_url":"https://api.github.com/repos/Obvious/zcache/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/Obvious/zcache/pulls/comments/8839865"},"html":{"href":"https://github.com/Obvious/zcache/pull/21#discussion_r8839865"},"pull_request":{"href":"https://api.github.com/repos/Obvious/zcache/pulls/21"}}}}