[Groonga-commit] droonga/express-droonga at c89612d [master] Remove "key" argument from the constructor of Entry

アーカイブの一覧に戻る

YUKI Hiroshi null+****@clear*****
Thu Mar 20 16:08:45 JST 2014


YUKI Hiroshi	2014-03-20 16:08:45 +0900 (Thu, 20 Mar 2014)

  New Revision: c89612d9e04de19bb151c5fb113b76449a19c10a
  https://github.com/droonga/express-droonga/commit/c89612d9e04de19bb151c5fb113b76449a19c10a

  Message:
    Remove "key" argument from the constructor of Entry

  Modified files:
    lib/response-cache/entry.js
    lib/response-cache/index.js
    lib/response-cache/rule.js
    test/response-cache/entry.test.js

  Modified: lib/response-cache/entry.js (+1 -5)
===================================================================
--- lib/response-cache/entry.js    2014-03-20 16:06:35 +0900 (c8d86f1)
+++ lib/response-cache/entry.js    2014-03-20 16:08:45 +0900 (3809030)
@@ -1,11 +1,7 @@
-function Entry(key, ttlInMilliSeconds) {
-  if (!key)
-    throw new Error('invalid cache key');
-
+function Entry(ttlInMilliSeconds) {
   if (!ttlInMilliSeconds)
     throw new Error('invalid TTL');
 
-  this.key = key;
   this.ttlInMilliSeconds = ttlInMilliSeconds;
   this.data = {
     status:  0,

  Modified: lib/response-cache/index.js (+1 -1)
===================================================================
--- lib/response-cache/index.js    2014-03-20 16:06:35 +0900 (380eab1)
+++ lib/response-cache/index.js    2014-03-20 16:08:45 +0900 (ac3dadd)
@@ -35,7 +35,7 @@ exports = module.exports = function(options) {
       if (cachedResponse) {
         sendCachedResponse(response, cachedResponse);
       } else {
-        var entry = rule.creteEntry(cacheKey);
+        var entry = rule.creteEntry();
         entry.hook(response, function(cachedResponse, ttl) {
           cache.set(cacheKey, cachedResponse, ttl);
         });

  Modified: lib/response-cache/rule.js (+2 -2)
===================================================================
--- lib/response-cache/rule.js    2014-03-20 16:06:35 +0900 (2ed56fd)
+++ lib/response-cache/rule.js    2014-03-20 16:08:45 +0900 (9ee67e2)
@@ -9,8 +9,8 @@ Rule.prototype = {
   match: function(request) {
     return this.regex.test(request.url);
   },
-  createEntry: function(key) {
-    return new Entry(key, this.ttlInMilliSeconds);
+  createEntry: function() {
+    return new Entry(this.ttlInMilliSeconds);
   }
 };
 exports = module.exports = Rule;

  Modified: test/response-cache/entry.test.js (+5 -5)
===================================================================
--- test/response-cache/entry.test.js    2014-03-20 16:06:35 +0900 (464b76f)
+++ test/response-cache/entry.test.js    2014-03-20 16:08:45 +0900 (6d48235)
@@ -5,18 +5,18 @@ var Entry = require('../../lib/response-cache/entry');
 suite('Response Cache Entry', function() {
   suite('isCachable', function() {
     test('not processed', function() {
-      var entry = new Entry('key', 10, {});
+      var entry = new Entry(10);
       assert.isFalse(entry.isCachable());
     });
 
     test('success', function() {
-      var entry = new Entry('key', 10, {});
+      var entry = new Entry(10);
       entry.data.status = 200;
       assert.isTrue(entry.isCachable());
     });
 
     test('error', function() {
-      var entry = new Entry('key', 10, {});
+      var entry = new Entry(10);
       entry.data.status = 400;
       assert.isFalse(entry.isCachable());
     });
@@ -24,7 +24,7 @@ suite('Response Cache Entry', function() {
 
   suite('tryStore', function() {
     test('success', function() {
-      var entry = new Entry('key', 10);
+      var entry = new Entry(10);
       entry.data.status = 200;
       var args = [];
       entry.tryStore(function() {
@@ -34,7 +34,7 @@ suite('Response Cache Entry', function() {
     });
 
     test('error', function() {
-      var entry = new Entry('key', 10);
+      var entry = new Entry(10);
       entry.data.status = 400;
       var args = [];
       entry.tryStore(function() {
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る