YUKI Hiroshi
yuki****@clear*****
Mon Apr 7 13:19:01 JST 2014
cacheのインスタンスを作ってそれを明示的にミドルウェアに渡す、というつく
りは、cache関係のモジュールの内部の都合が外に染み出ている感じがして、よ
くないのではないかと思いました。
var cache = new droonga.cache({
size: cache
});
application.use('/cache/statistics',
cache.statistics);
application.use(cache.middleware({
rules: [
{
regex: /^\//,
ttlInMilliSeconds: 1000
}
]
}));
という感じで初期化するスタイルの方がいいと自分は思うのですが、どうでしょ
うか。
Kouhei Sutou wrote:
> Author
> Kouhei Sutou <kou �� clear-code.com>
> Date
> 2014-04-07 13:08:36 +0900 (Mon, 07 Apr 2014)
> New Revision
> ab2834c0c07980ae82062f527f1d062459f2604c
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c>
> Message
>
> Split cache and middlewares that use cache
>
> API is changed.
>
> Before:
>
> application.use(droonga.cache({
> size: cacheSize,
> rules: [
> {
> regex: /^\//,
> ttlInMilliSeconds: 1000
> }
> ]
> }));
>
> After:
>
> var cache = new droonga.cache({
> size: cache
> });
> application.use('/cache/statistics',
> droonga.middleware.cacheStatistics(cache));
> application.use(droonga.middleware.cache(cache, {
> rules: [
> {
> regex: /^\//,
> ttlInMilliSeconds: 1000
> }
> ]
> }));
>
> Added files
>
> * lib/cache/index.js
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#diff-1>
> * lib/middleware/cache-statistics/index.js
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#diff-2>
> * lib/middleware/cache/index.js
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#diff-4>
> * test/cache.test.js
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#diff-8>
> * test/middleware/cache-statistics/middleware.test.js
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#diff-9>
>
> Removed files
>
> * lib/response-cache/cache.js
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#diff-6>
> * lib/response-cache/index.js
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#diff-7>
> * test/response-cache/cache.test.js
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#diff-13>
>
> Modified files
>
> * index.js
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#diff-0>
>
> Renamed files
>
> * lib/middleware/cache/entry.js
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#diff-3>
> (from lib/response-cache/entry.js)
> * lib/middleware/cache/rule.js
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#diff-5>
> (from lib/response-cache/rule.js)
> * test/middleware/cache/entry.test.js
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#diff-10>
> (from test/response-cache/entry.test.js)
> * test/middleware/cache/middleware.test.js
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#diff-11>
> (from test/response-cache/middleware.test.js)
> * test/middleware/cache/rule.test.js
> <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#diff-12>
> (from test/response-cache/rule.test.js)
>
> Modified: index.js (+5 -1)
> ===================================================================
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L0L38>
> 39 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L0L39>
> 40 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L0L40>
> 41 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L0L41>
> 42 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L0L42>
>
>
>
>
>
>
>
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L0R38>
> 39 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L0R39>
> 40 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L0R40>
> 41 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L0R41>
>
> 42 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L0R42>
> 43 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L0R43>
> 44 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L0R44>
> 45 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L0R45>
> 46 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L0R46>
>
>
>
> @@ -39,4 +39,8 @@express.application.droonga = function(params) {
> require('./lib/adapter/api').exportTo(exports);
>
> exports.command = require('./lib/adapter/command');
> -exports.cache = require('./lib/response-cache');
> +exports.cache = require('./lib/cache');
> +exports.middleware = {
> + cacheStatistics: require('./lib/middleware/cache-statistics'),
> + cache: require('./lib/middleware/cache')
> +};
>
> Added: lib/cache/index.js (+50 -0) 100644
> ===================================================================
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1L-1>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R0>
> 1 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R1>
> 2 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R2>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R3>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R4>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R5>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R6>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R7>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R8>
> 9 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R9>
> 10 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R10>
> 11 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R11>
> 12 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R12>
> 13 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R13>
> 14 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R14>
> 15 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R15>
> 16 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R16>
> 17 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R17>
> 18 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R18>
> 19 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R19>
> 20 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R20>
> 21 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R21>
> 22 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R22>
> 23 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R23>
> 24 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R24>
> 25 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R25>
> 26 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R26>
> 27 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R27>
> 28 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R28>
> 29 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R29>
> 30 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R30>
> 31 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R31>
> 32 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R32>
> 33 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R33>
> 34 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R34>
> 35 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R35>
> 36 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R36>
> 37 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R37>
> 38 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R38>
> 39 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R39>
> 40 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R40>
> 41 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R41>
> 42 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R42>
> 43 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R43>
> 44 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R44>
> 45 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R45>
> 46 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R46>
> 47 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R47>
> 48 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R48>
> 49 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R49>
> 50 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L1R50>
>
>
>
> @@ -0,0 +1,50 @@
> +var createCache = require('uber-cache');
> +
> +var defaultSize = 100;
> +
> +function normalizeOptions(options) {
> + options = options || {};
> +
> + options.size = options.size || defaultSize;
> +
> + return options;
> +}
> +
> +function Cache(options) {
> + options = normalizeOptions(options);
> + this.cache = createCache({
> + size: options.size
> + });
> + this.nGets = 0;
> + this.nHits = 0;
> +}
> +Cache.prototype = {
> + 'get': function(key, callback) {
> + return this.cache.get(key, function(error, cachedResponse) {
> + this.nGets++;
> + if (cachedResponse) {
> + this.nHits++;
> + }
> + callback(error, cachedResponse);
> + }.bind(this));
> + },
> +
> + 'set': function(key, value, ttl, callback) {
> + return this.cache.set(key, value, ttl, callback);
> + },
> +
> + getStatistics: function() {
> + var hitRatio;
> + if (this.nGets == 0) {
> + hitRatio = 0.0;
> + } else {
> + hitRatio = (this.nHits / this.nGets) * 100;
> + }
> + return {
> + "nGets": this.nGets,
> + "nHits": this.nHits,
> + "hitRatio": hitRatio
> + };
> + }
> +};
> +module.exports = Cache;
>
> Added: lib/middleware/cache-statistics/index.js (+5 -0) 100644
> ===================================================================
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L2L-1>
>
>
>
>
>
>
>
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L2R0>
> 1 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L2R1>
> 2 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L2R2>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L2R3>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L2R4>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L2R5>
>
>
>
> @@ -0,0 +1,5 @@
> +module.exports = function middleware(cache) {
> + return function(request, response, next) {
> + response.jsonp(200, cache.getStatistics());
> + }
> +}
>
> Renamed: lib/middleware/cache/entry.js (+0 -0) 100%
> ===================================================================
>
>
>
>
>
> Added: lib/middleware/cache/index.js (+92 -0) 100644
> ===================================================================
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4L-1>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R0>
> 1 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R1>
> 2 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R2>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R3>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R4>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R5>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R6>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R7>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R8>
> 9 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R9>
> 10 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R10>
> 11 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R11>
> 12 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R12>
> 13 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R13>
> 14 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R14>
> 15 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R15>
> 16 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R16>
> 17 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R17>
> 18 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R18>
> 19 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R19>
> 20 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R20>
> 21 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R21>
> 22 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R22>
> 23 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R23>
> 24 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R24>
> 25 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R25>
> 26 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R26>
> 27 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R27>
> 28 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R28>
> 29 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R29>
> 30 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R30>
> 31 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R31>
> 32 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R32>
> 33 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R33>
> 34 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R34>
> 35 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R35>
> 36 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R36>
> 37 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R37>
> 38 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R38>
> 39 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R39>
> 40 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R40>
> 41 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R41>
> 42 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R42>
> 43 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R43>
> 44 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R44>
> 45 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R45>
> 46 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R46>
> 47 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R47>
> 48 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R48>
> 49 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R49>
> 50 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R50>
> 51 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R51>
> 52 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R52>
> 53 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R53>
> 54 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R54>
> 55 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R55>
> 56 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R56>
> 57 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R57>
> 58 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R58>
> 59 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R59>
> 60 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R60>
> 61 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R61>
> 62 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R62>
> 63 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R63>
> 64 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R64>
> 65 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R65>
> 66 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R66>
> 67 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R67>
> 68 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R68>
> 69 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R69>
> 70 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R70>
> 71 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R71>
> 72 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R72>
> 73 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R73>
> 74 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R74>
> 75 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R75>
> 76 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R76>
> 77 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R77>
> 78 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R78>
> 79 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R79>
> 80 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R80>
> 81 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R81>
> 82 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R82>
> 83 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R83>
> 84 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R84>
> 85 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R85>
> 86 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R86>
> 87 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R87>
> 88 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R88>
> 89 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R89>
> 90 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R90>
> 91 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R91>
> 92 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L4R92>
>
>
>
> @@ -0,0 +1,92 @@
> +var Entry = require('./entry');
> +var Rule = require('./rule');
> +
> +var defaultTTLInMilliSeconds = 60 * 1000;
> +
> +function getNormalizedTTLInMilliSeconds(options) {
> + var ttlInSeconds = options.ttlInSeconds || 0;
> + return options.ttl ||
> + options.ttlInMilliSeconds ||
> + (ttlInSeconds * 1000) ||
> + 0;
> +}
> +
> +function validateRules(rules) {
> + if (!Array.isArray(rules))
> + throw new Error('rules must be an array');
> +
> + if (!rules.length)
> + throw new Error('you must specify one or more rules');
> +}
> +
> +function createRules(options) {
> + var ttlInMilliSeconds =
> + getNormalizedTTLInMilliSeconds(options) ||
> + defaultTTLInMilliSeconds;
> +
> + validateRules(options.rules);
> +
> + return options.rules.map(function(rule) {
> + rule.ttlInMilliSeconds = getNormalizedTTLInMilliSeconds(rule) ||
> + ttlInMilliSeconds;
> + return new Rule(rule);
> + });
> +}
> +
> +function findRule(rules, request) {
> + if (request.method != 'GET')
> + return null;
> +
> + var foundRule = null;
> + rules.some(function(rule) {
> + if (rule.match(request))
> + return foundRule = rule;
> + });
> + return foundRule;
> +}
> +
> +function generateKey(request) {
> + return request.method + '\n' + request.url;
> +}
> +
> +function sendCachedResponse(response, cached) {
> + response.statusCode = cached.status;
> + Object.keys(cached.headers).forEach(function(key) {
> + response.setHeader(key, cached.headers[key]);
> + });
> + response.setHeader('X-Droonga-Cached', 'yes');
> + cached.body.forEach(function(chunk) {
> + response.write(chunk.data, chunk.encoding);
> + });
> + response.end();
> +}
> +
> +module.exports = function cacheMiddleware(cache, options) {
> + var rules = createRules(options);
> +
> + return function(request, response, next) {
> + var rule = findRule(rules, request);
> + if (!rule) {
> + next();
> + return;
> + }
> +
> + var cacheKey = generateKey(request);
> + cache.get(cacheKey, function(error, cachedResponse) {
> + if (error) {
> + console.error(error);
> + return;
> + }
> +
> + if (cachedResponse) {
> + sendCachedResponse(response, cachedResponse);
> + } else {
> + var entry = new Entry();
> + entry.hook(response, function(cachedResponse) {
> + cache.set(cacheKey, cachedResponse, rule.ttlInMilliSeconds);
> + });
> + next();
> + }
> + });
> + };
> +};
>
> Renamed: lib/middleware/cache/rule.js (+2 -4) 65%
> ===================================================================
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5L0>
> 1 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5L1>
> 2 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5L2>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5L3>
>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5L4>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5L5>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5L6>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5L7>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5L8>
> 9 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5L9>
> 10 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5L10>
>
> 11 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5L11>
> 12 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5L12>
> 13 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5L13>
>
>
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5R0>
>
>
>
> 1 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5R1>
> 2 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5R2>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5R3>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5R4>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5R5>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5R6>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5R7>
>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5R8>
> 9 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5R9>
> 10 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5R10>
> 11 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L5R11>
>
>
>
> @@ -1,13 +1,11 @@
> -function Rule(rule, options) {
> - options = options || {};
> -
> +function Rule(rule) {
> if (!rule)
> throw new Error('no rule is given');
> if (!rule.regex)
> throw new Error('rule must have "regex"');
>
> this.regex = rule.regex;
> - this.ttlInMilliSeconds = rule.ttlInMilliSeconds || options.ttlInMilliSeconds || 0;
> + this.ttlInMilliSeconds = rule.ttlInMilliSeconds || 0;
> }
> Rule.prototype = {
> match: function(request) {
>
> Deleted: lib/response-cache/cache.js (+0 -87) 100644
> ===================================================================
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L0>
> 1 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L1>
> 2 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L2>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L3>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L4>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L5>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L6>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L7>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L8>
> 9 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L9>
> 10 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L10>
> 11 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L11>
> 12 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L12>
> 13 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L13>
> 14 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L14>
> 15 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L15>
> 16 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L16>
> 17 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L17>
> 18 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L18>
> 19 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L19>
> 20 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L20>
> 21 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L21>
> 22 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L22>
> 23 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L23>
> 24 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L24>
> 25 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L25>
> 26 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L26>
> 27 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L27>
> 28 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L28>
> 29 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L29>
> 30 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L30>
> 31 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L31>
> 32 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L32>
> 33 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L33>
> 34 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L34>
> 35 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L35>
> 36 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L36>
> 37 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L37>
> 38 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L38>
> 39 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L39>
> 40 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L40>
> 41 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L41>
> 42 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L42>
> 43 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L43>
> 44 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L44>
> 45 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L45>
> 46 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L46>
> 47 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L47>
> 48 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L48>
> 49 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L49>
> 50 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L50>
> 51 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L51>
> 52 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L52>
> 53 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L53>
> 54 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L54>
> 55 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L55>
> 56 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L56>
> 57 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L57>
> 58 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L58>
> 59 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L59>
> 60 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L60>
> 61 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L61>
> 62 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L62>
> 63 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L63>
> 64 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L64>
> 65 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L65>
> 66 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L66>
> 67 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L67>
> 68 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L68>
> 69 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L69>
> 70 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L70>
> 71 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L71>
> 72 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L72>
> 73 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L73>
> 74 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L74>
> 75 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L75>
> 76 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L76>
> 77 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L77>
> 78 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L78>
> 79 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L79>
> 80 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L80>
> 81 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L81>
> 82 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L82>
> 83 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L83>
> 84 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L84>
> 85 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L85>
> 86 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L86>
> 87 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6L87>
>
>
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L6R-1>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> @@ -1,87 +0,0 @@
> -var createCache = require('uber-cache');
> -var Rule = require('./rule');
> -
> -var defaultSize = 100;
> -var defaultTTLInMilliSeconds = 60 * 1000;
> -
> -function getNormalizedTTLInMilliSeconds(options) {
> - var ttlInSeconds = options.ttlInSeconds || 0;
> - return options.ttl ||
> - options.ttlInMilliSeconds ||
> - (ttlInSeconds * 1000) ||
> - 0;
> -}
> -
> -function normalizeOptions(options) {
> - options = options || {};
> -
> - if (!Array.isArray(options.rules))
> - throw new Error('rules must be an array');
> -
> - if (!options.rules.length)
> - throw new Error('you must specify one or more rules');
> -
> - options.size = options.size || defaultSize;
> - options.ttlInMilliSeconds = getNormalizedTTLInMilliSeconds(options) ||
> - defaultTTLInMilliSeconds;
> -
> - options.rules = options.rules.map(function(rule) {
> - rule.ttlInMilliSeconds = getNormalizedTTLInMilliSeconds(rule) ||
> - options.ttlInMilliSeconds;
> - return new Rule(rule, options);
> - });
> -
> - return options;
> -}
> -
> -function Cache(options) {
> - options = normalizeOptions(options);
> - this.cache = createCache({
> - size: options.size
> - });
> - this.rules = options.rules;
> - this.nGets = 0;
> - this.nHits = 0;
> -}
> -Cache.prototype = {
> - 'get': function(key, callback) {
> - return this.cache.get(key, function(error, cachedResponse) {
> - this.nGets++;
> - if (cachedResponse) {
> - this.nHits++;
> - }
> - callback(error, cachedResponse);
> - }.bind(this));
> - },
> -
> - 'set': function(key, value, ttl, callback) {
> - return this.cache.set(key, value, ttl, callback);
> - },
> -
> - getRule: function(request) {
> - if (request.method != 'GET')
> - return null;
> -
> - var foundRule = null;
> - this.rules.some(function(rule) {
> - if (rule.match(request))
> - return foundRule = rule;
> - });
> - return foundRule;
> - },
> -
> - getStatistics: function() {
> - var hitRatio;
> - if (this.nGets == 0) {
> - hitRatio = 0.0;
> - } else {
> - hitRatio = (this.nHits / this.nGets) * 100;
> - }
> - return {
> - "nGets": this.nGets,
> - "nHits": this.nHits,
> - "hitRatio": hitRatio
> - };
> - }
> -};
> -module.exports = Cache;
>
> Deleted: lib/response-cache/index.js (+0 -53) 100644
> ===================================================================
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L0>
> 1 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L1>
> 2 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L2>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L3>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L4>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L5>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L6>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L7>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L8>
> 9 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L9>
> 10 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L10>
> 11 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L11>
> 12 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L12>
> 13 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L13>
> 14 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L14>
> 15 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L15>
> 16 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L16>
> 17 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L17>
> 18 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L18>
> 19 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L19>
> 20 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L20>
> 21 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L21>
> 22 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L22>
> 23 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L23>
> 24 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L24>
> 25 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L25>
> 26 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L26>
> 27 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L27>
> 28 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L28>
> 29 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L29>
> 30 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L30>
> 31 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L31>
> 32 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L32>
> 33 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L33>
> 34 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L34>
> 35 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L35>
> 36 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L36>
> 37 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L37>
> 38 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L38>
> 39 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L39>
> 40 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L40>
> 41 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L41>
> 42 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L42>
> 43 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L43>
> 44 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L44>
> 45 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L45>
> 46 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L46>
> 47 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L47>
> 48 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L48>
> 49 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L49>
> 50 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L50>
> 51 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L51>
> 52 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L52>
> 53 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7L53>
>
>
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L7R-1>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> @@ -1,53 +0,0 @@
> -var Entry = require('./entry');
> -
> -function generateKey(request) {
> - return request.method + '\n' + request.url;
> -}
> -
> -function sendCachedResponse(response, cached) {
> - response.statusCode = cached.status;
> - Object.keys(cached.headers).forEach(function(key) {
> - response.setHeader(key, cached.headers[key]);
> - });
> - response.setHeader('X-Droonga-Cached', 'yes');
> - cached.body.forEach(function(chunk) {
> - response.write(chunk.data, chunk.encoding);
> - });
> - response.end();
> -}
> -
> -module.exports.Cache = require('./cache');
> -
> -module.exports.statisticsMiddleware = function statisticsMiddleware(cache) {
> - return function(request, response, next) {
> - response.jsonp(200, cache.getStatistics());
> - }
> -}
> -
> -module.exports.middleware = function middleware(cache) {
> - return function(request, response, next) {
> - var rule = cache.getRule(request);
> - if (!rule) {
> - next();
> - return;
> - }
> -
> - var cacheKey = generateKey(request);
> - cache.get(cacheKey, function(error, cachedResponse) {
> - if (error) {
> - console.error(error);
> - return;
> - }
> -
> - if (cachedResponse) {
> - sendCachedResponse(response, cachedResponse);
> - } else {
> - var entry = new Entry();
> - entry.hook(response, function(cachedResponse) {
> - cache.set(cacheKey, cachedResponse, rule.ttlInMilliSeconds);
> - });
> - next();
> - }
> - });
> - };
> -};
>
> Added: test/cache.test.js (+49 -0) 100644
> ===================================================================
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8L-1>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R0>
> 1 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R1>
> 2 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R2>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R3>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R4>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R5>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R6>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R7>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R8>
> 9 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R9>
> 10 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R10>
> 11 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R11>
> 12 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R12>
> 13 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R13>
> 14 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R14>
> 15 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R15>
> 16 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R16>
> 17 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R17>
> 18 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R18>
> 19 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R19>
> 20 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R20>
> 21 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R21>
> 22 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R22>
> 23 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R23>
> 24 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R24>
> 25 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R25>
> 26 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R26>
> 27 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R27>
> 28 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R28>
> 29 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R29>
> 30 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R30>
> 31 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R31>
> 32 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R32>
> 33 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R33>
> 34 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R34>
> 35 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R35>
> 36 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R36>
> 37 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R37>
> 38 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R38>
> 39 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R39>
> 40 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R40>
> 41 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R41>
> 42 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R42>
> 43 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R43>
> 44 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R44>
> 45 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R45>
> 46 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R46>
> 47 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R47>
> 48 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R48>
> 49 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L8R49>
>
>
>
> @@ -0,0 +1,49 @@
> +var assert = require('chai').assert;
> +
> +var Cache = require('../lib/cache');
> +
> +suite('Cache', function() {
> + suite('statistics', function() {
> + var cache;
> + setup(function() {
> + cache = new Cache();
> + });
> +
> + test('nGets', function() {
> + assert.equal(cache.getStatistics().nGets, 0);
> + cache.get('key', function(error, cachedResponse) {
> + });
> + assert.equal(cache.getStatistics().nGets, 1);
> + });
> +
> + test('nHits', function() {
> + cache.set('key', 'value');
> + assert.equal(cache.getStatistics().nHits, 0);
> + cache.get('key', function(error, cachedResponse) {
> + });
> + assert.equal(cache.getStatistics().nHits, 1);
> + });
> +
> + suite('hitRatio', function() {
> + test('0 gets', function() {
> + assert.equal(cache.getStatistics().hitRatio, 0.0);
> + });
> +
> + test('0 hits', function() {
> + cache.get('key', function(error, cachedResponse) {
> + });
> + assert.equal(cache.getStatistics().hitRatio, 0.0);
> + });
> +
> + test('1/2 hits', function() {
> + cache.get('key', function(error, cachedResponse) {
> + });
> + cache.set('key', 'value');
> + cache.get('key', function(error, cachedResponse) {
> + });
> + assert.equal(cache.getStatistics().hitRatio, 50.0);
> + });
> + });
> + });
> +});
> +
>
> Added: test/middleware/cache-statistics/middleware.test.js (+39 -0) 100644
> ===================================================================
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9L-1>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R0>
> 1 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R1>
> 2 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R2>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R3>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R4>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R5>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R6>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R7>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R8>
> 9 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R9>
> 10 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R10>
> 11 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R11>
> 12 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R12>
> 13 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R13>
> 14 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R14>
> 15 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R15>
> 16 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R16>
> 17 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R17>
> 18 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R18>
> 19 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R19>
> 20 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R20>
> 21 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R21>
> 22 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R22>
> 23 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R23>
> 24 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R24>
> 25 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R25>
> 26 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R26>
> 27 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R27>
> 28 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R28>
> 29 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R29>
> 30 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R30>
> 31 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R31>
> 32 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R32>
> 33 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R33>
> 34 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R34>
> 35 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R35>
> 36 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R36>
> 37 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R37>
> 38 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R38>
> 39 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L9R39>
>
>
>
> @@ -0,0 +1,39 @@
> +var client = require('supertest');
> +var express = require('express');
> +
> +var assert = require('chai').assert;
> +
> +var Cache = require('../../../lib/cache');
> +var middleware = require('../../../lib/middleware/cache-statistics');
> +
> +suite('middleware - cache statistics -', function() {
> + var application;
> + var cache;
> + setup(function() {
> + cache = new Cache();
> + application = express();
> + application.use('/cache/statistics', middleware(cache));
> + });
> +
> + test('json', function(done) {
> + client(application)
> + .get('/cache/statistics')
> + .expect(200)
> + .end(function(error, response) {
> + if (error)
> + return done(error);
> +
> + var statistics = {
> + nGets: 0,
> + nHits: 0,
> + hitRatio: 0.0
> + };
> + try {
> + assert.deepEqual(response.body, statistics);
> + } catch (error) {
> + return done(error);
> + }
> + done();
> + });
> + });
> +});
>
> Renamed: test/middleware/cache/entry.test.js (+2 -2) 90%
> ===================================================================
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10L0>
> 1 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10L1>
> 2 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10L2>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10L3>
>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10L4>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10L5>
>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10L6>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10L7>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10L8>
>
>
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10R0>
> 1 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10R1>
> 2 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10R2>
>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10R3>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10R4>
>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10R5>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10R6>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10R7>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L10R8>
>
>
>
> @@ -1,8 +1,8 @@
> var assert = require('chai').assert;
>
> -var Entry = require('../../lib/response-cache/entry');
> +var Entry = require('../../../lib/middleware/cache/entry');
>
> -suite('Response Cache Entry', function() {
> +suite('middleware - cache - Entry', function() {
> suite('isCachable', function() {
> test('not processed', function() {
> var entry = new Entry();
>
> Renamed: test/middleware/cache/middleware.test.js (+152 -45) 68%
> ===================================================================
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L2>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L3>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L4>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L5>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L6>
>
>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L7>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L8>
>
> 9 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L9>
> 10 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L10>
> 11 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L11>
> 12 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L12>
>
>
>
> 13 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L13>
> 14 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L14>
> 15 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L15>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> 16 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L16>
> 17 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L17>
> 18 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L18>
> 19 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L19>
> 20 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L20>
> 21 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L21>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L226>
> 227 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L227>
> 228 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L228>
> 229 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L229>
> 230 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L230>
>
> 231 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L231>
>
>
> 232 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L232>
> 233 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L233>
> 234 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L234>
> 235 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L235>
> 236 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L236>
>
> 237 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L237>
> 238 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L238>
> 239 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L239>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L277>
> 278 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L278>
> 279 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L279>
> 280 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L280>
> 281 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L281>
>
> 282 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L282>
> 283 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L283>
> 284 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L284>
> 285 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L285>
> 286 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L286>
> 287 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L287>
>
> 288 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L288>
> 289 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L289>
> 290 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L290>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L310>
> 311 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L311>
> 312 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L312>
> 313 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L313>
> 314 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L314>
>
> 315 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L315>
> 316 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L316>
> 317 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L317>
> 318 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L318>
> 319 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L319>
>
> 320 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L320>
> 321 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L321>
> 322 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L322>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L340>
> 341 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L341>
> 342 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L342>
> 343 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L343>
> 344 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L344>
> 345 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L345>
> 346 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L346>
> 347 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L347>
> 348 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L348>
> 349 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L349>
> 350 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L350>
> 351 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L351>
> 352 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L352>
> 353 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L353>
> 354 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L354>
> 355 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L355>
> 356 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L356>
> 357 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L357>
> 358 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L358>
> 359 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L359>
> 360 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L360>
> 361 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L361>
> 362 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L362>
> 363 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L363>
> 364 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L364>
> 365 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L365>
> 366 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L366>
> 367 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L367>
> 368 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L368>
> 369 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L369>
> 370 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L370>
> 371 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L371>
> 372 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L372>
> 373 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L373>
> 374 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L374>
> 375 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L375>
> 376 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11L376>
>
>
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R2>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R3>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R4>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R5>
>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R6>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R7>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R8>
>
> 9 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R9>
> 10 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R10>
> 11 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R11>
> 12 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R12>
>
> 13 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R13>
> 14 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R14>
> 15 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R15>
> 16 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R16>
> 17 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R17>
> 18 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R18>
> 19 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R19>
> 20 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R20>
> 21 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R21>
> 22 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R22>
> 23 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R23>
> 24 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R24>
> 25 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R25>
> 26 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R26>
> 27 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R27>
> 28 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R28>
> 29 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R29>
> 30 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R30>
> 31 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R31>
> 32 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R32>
> 33 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R33>
> 34 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R34>
> 35 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R35>
> 36 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R36>
> 37 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R37>
> 38 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R38>
> 39 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R39>
> 40 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R40>
> 41 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R41>
> 42 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R42>
> 43 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R43>
> 44 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R44>
> 45 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R45>
> 46 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R46>
> 47 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R47>
> 48 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R48>
> 49 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R49>
> 50 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R50>
> 51 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R51>
> 52 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R52>
> 53 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R53>
> 54 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R54>
> 55 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R55>
> 56 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R56>
> 57 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R57>
> 58 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R58>
> 59 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R59>
> 60 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R60>
> 61 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R61>
> 62 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R62>
> 63 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R63>
> 64 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R64>
> 65 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R65>
> 66 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R66>
> 67 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R67>
> 68 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R68>
> 69 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R69>
> 70 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R70>
> 71 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R71>
> 72 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R72>
> 73 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R73>
> 74 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R74>
> 75 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R75>
> 76 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R76>
> 77 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R77>
> 78 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R78>
> 79 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R79>
> 80 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R80>
> 81 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R81>
> 82 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R82>
> 83 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R83>
> 84 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R84>
> 85 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R85>
> 86 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R86>
> 87 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R87>
> 88 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R88>
> 89 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R89>
> 90 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R90>
> 91 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R91>
> 92 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R92>
> 93 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R93>
> 94 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R94>
> 95 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R95>
> 96 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R96>
> 97 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R97>
> 98 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R98>
> 99 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R99>
> 100 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R100>
> 101 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R101>
> 102 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R102>
> 103 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R103>
> 104 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R104>
> 105 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R105>
> 106 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R106>
> 107 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R107>
> 108 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R108>
> 109 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R109>
> 110 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R110>
> 111 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R111>
> 112 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R112>
> 113 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R113>
> 114 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R114>
> 115 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R115>
> 116 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R116>
> 117 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R117>
> 118 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R118>
> 119 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R119>
> 120 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R120>
> 121 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R121>
> 122 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R122>
> 123 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R123>
> 124 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R124>
> 125 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R125>
> 126 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R126>
> 127 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R127>
> 128 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R128>
> 129 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R129>
> 130 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R130>
> 131 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R131>
> 132 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R132>
> 133 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R133>
> 134 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R134>
> 135 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R135>
> 136 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R136>
> 137 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R137>
> 138 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R138>
> 139 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R139>
> 140 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R140>
> 141 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R141>
> 142 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R142>
> 143 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R143>
> 144 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R144>
> 145 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R145>
> 146 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R146>
> 147 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R147>
> 148 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R148>
> 149 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R149>
> 150 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R150>
> 151 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R151>
> 152 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R152>
> 153 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R153>
> 154 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R154>
> 155 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R155>
> 156 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R156>
> 157 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R157>
>
>
> 158 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R158>
> 159 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R159>
> 160 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R160>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R365>
> 366 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R366>
> 367 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R367>
> 368 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R368>
>
> 369 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R369>
> 370 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R370>
> 371 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R371>
> 372 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R372>
> 373 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R373>
> 374 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R374>
> 375 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R375>
>
>
> 376 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R376>
> 377 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R377>
> 378 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R378>
> 379 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R379>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R417>
> 418 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R418>
> 419 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R419>
> 420 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R420>
>
> 421 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R421>
> 422 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R422>
> 423 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R423>
> 424 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R424>
> 425 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R425>
>
>
> 426 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R426>
> 427 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R427>
> 428 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R428>
> 429 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R429>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R449>
> 450 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R450>
> 451 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R451>
> 452 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R452>
>
> 453 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R453>
> 454 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R454>
> 455 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R455>
> 456 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R456>
>
>
> 457 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R457>
> 458 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R458>
> 459 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R459>
> 460 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R460>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R478>
> 479 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R479>
> 480 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R480>
> 481 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R481>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> 482 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R482>
> 483 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L11R483>
>
>
>
> @@ -3,19 +3,158 @@var express = require('express');
>
> var assert = require('chai').assert;
>
> -var responseCache = require('../../lib/response-cache');
> +var Cache = require('../../../lib/cache');
> +var middleware = require('../../../lib/middleware/cache');
>
> -suite('Response Cache Middleware', function() {
> +suite('middleware - cache -', function() {
> var application;
> var cache;
> setup(function() {
> - cache = new responseCache.Cache({
> + cache = new Cache();
> + application = express();
> + application.use(middleware(cache, {
> rules: [
> { regex: /cached/ }
> ]
> + }));
> + });
> +
> + suite('required parameters', function() {
> + test('missing rules', function() {
> + assert.throw(function() {
> + middleware(cache, {
> + });
> + }, Error);
> + });
> +
> + test('not-array rules', function() {
> + assert.throw(function() {
> + middleware(cache, {
> + rules: {
> + 'foo' : {
> + ttl: 10
> + }
> + }
> + });
> + }, Error);
> + });
> + });
> +
> + suite('findRule -', function() {
> + suite('a rule -', function() {
> + setup(function() {
> + application = express();
> + application.use(middleware(cache, {
> + rules: [
> + { regex: /^\/cache-target\// }
> + ]
> + }));
> + });
> +
> + test('non-GET requests', function(done) {
> + application.post('/cache-target/path', function(request, response) {
> + response.send(200, 'POST - success');
> + });
> + client(application)
> + .post('/cache-target/path')
> + .end(function(error, response) {
> + if (error)
> + return done(error);
> +
> + var nGets = cache.getStatistics().nGets;
> + try {
> + assert.deepEqual(nGets, 0);
> + } catch (error) {
> + return done(error);
> + }
> + done();
> + });
> + });
> +
> + test('not matched', function(done) {
> + application.get('/not-cache-target/path', function(request, response) {
> + response.send(200, 'GET - success');
> + });
> + client(application)
> + .get('/not-cache-target/path')
> + .end(function(error, response) {
> + if (error)
> + return done(error);
> +
> + var nGets = cache.getStatistics().nGets;
> + try {
> + assert.deepEqual(nGets, 0);
> + } catch (error) {
> + return done(error);
> + }
> + done();
> + });
> + });
> +
> + test('matched to a rule', function(done) {
> + application.get('/cache-target/path', function(request, response) {
> + response.send(200, 'GET - success');
> + });
> + client(application)
> + .get('/cache-target/path')
> + .end(function(error, response) {
> + if (error)
> + return done(error);
> +
> + var nGets = cache.getStatistics().nGets;
> + try {
> + assert.deepEqual(nGets, 1);
> + } catch (error) {
> + return done(error);
> + }
> + done();
> + });
> + });
> + });
> +
> + suite('multiple rules', function() {
> + setup(function() {
> + application = express();
> + });
> +
> + test('matched to multiple rules', function(done) {
> + var notUsedTtlInMilliSeconds = 1;
> + application.use(middleware(cache, {
> + rules: [
> + {
> + regex: /^\/cache-target/,
> + ttlInMilliSeconds: 1000
> + },
> + {
> + regex: /^\/cache-target-not-used/,
> + ttlInMilliSeconds: notUsedTtlInMilliSeconds
> + }
> + ]
> + }));
> + application.get('/cache-target-not-used', function(request, response) {
> + response.send(200, 'GET - success');
> + });
> +
> + client(application)
> + .get('/cache-target-not-used')
> + .end(function(error, response) {
> + if (error)
> + return done(error);
> +
> + setTimeout(function() {
> + client(application)
> + .get('/cache-target-not-used')
> + .expect(200)
> + .expect('X-Droonga-Cached', 'yes')
> + .end(function(error, response) {
> + if (error)
> + return done(error);
> + done();
> + });
> + }, notUsedTtlInMilliSeconds + 1);
> + });
> + });
> });
> - application = express();
> - application.use(responseCache.middleware(cache));
> });
>
> test('cached', function(done) {
> @@ -227,13 +366,14 @@suite('Response Cache Middleware', function() {
>
> test('size over', function(done) {
> application = express();
> - cache = new responseCache.Cache({
> + cache = new Cache({
> size: 1,
> + });
> + application.use(middleware(cache, {
> rules: [
> { regex: /cached/ }
> ]
> - });
> - application.use(responseCache.middleware(cache));
> + }));
> application.get('/cached/first', function(request, response) {
> response.json(200, 'OK');
> });
> @@ -278,13 +418,12 @@suite('Response Cache Middleware', function() {
>
> test('expired by global TTL', function(done) {
> application = express();
> - cache = new responseCache.Cache({
> + application.use(middleware(cache, {
> ttlInMilliSeconds: 10,
> rules: [
> { regex: /cached/ }
> ]
> - });
> - application.use(responseCache.middleware(cache));
> + }));
> application.get('/cached/expired', function(request, response) {
> response.json(200, 'OK');
> });
> @@ -311,12 +450,11 @@suite('Response Cache Middleware', function() {
>
> test('expired by TTL for a rule', function(done) {
> application = express();
> - cache = new responseCache.Cache({
> + application.use(middleware(cache, {
> rules: [
> { regex: /cached/, ttlInMilliSeconds: 10 }
> ]
> - });
> - application.use(responseCache.middleware(cache));
> + }));
> application.get('/cached/expired', function(request, response) {
> response.json(200, 'OK');
> });
> @@ -341,36 +479,5 @@suite('Response Cache Middleware', function() {
> });
> });
> });
> -
> - suite('statistics', function() {
> - setup(function() {
> - application = express();
> - application.use("/cache/statistics",
> - responseCache.statisticsMiddleware(cache));
> - application.use(responseCache.middleware(cache));
> - });
> -
> - test('json', function(done) {
> - client(application)
> - .get('/cache/statistics')
> - .expect(200)
> - .end(function(error, response) {
> - if (error)
> - return done(error);
> -
> - var statistics = {
> - nGets: 0,
> - nHits: 0,
> - hitRatio: 0.0
> - };
> - try {
> - assert.deepEqual(response.body, statistics);
> - } catch (error) {
> - return done(error);
> - }
> - done();
> - });
> - });
> - });
> });
>
>
> Renamed: test/middleware/cache/rule.test.js (+4 -11) 59%
> ===================================================================
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L0>
> 1 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L1>
> 2 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L2>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L3>
>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L4>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L5>
>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L6>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L7>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L8>
> 9 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L9>
> 10 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L10>
> 11 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L11>
> 12 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L12>
> 13 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L13>
> 14 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L14>
> 15 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L15>
> 16 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L16>
> 17 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L17>
> 18 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L18>
> 19 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L19>
> 20 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L20>
>
>
> 21 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L21>
> 22 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L22>
> 23 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12L23>
>
>
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R0>
> 1 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R1>
> 2 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R2>
>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R3>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R4>
>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R5>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R6>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R7>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R8>
> 9 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R9>
> 10 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R10>
> 11 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R11>
>
>
>
>
>
>
>
>
>
> 12 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R12>
> 13 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R13>
> 14 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R14>
> 15 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R15>
> 16 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L12R16>
>
>
>
> @@ -1,23 +1,16 @@
> var assert = require('chai').assert;
>
> -var Rule = require('../../lib/response-cache/rule');
> +var Rule = require('../../../lib/middleware/cache/rule');
>
> -suite('Response Cache Rule', function() {
> +suite('middleware - cache - Rule', function() {
> suite('ttlInMilliSeconds', function() {
> test('default', function() {
> var rule = new Rule({ regex: /./, ttlInMilliSeconds: null });
> assert.equal(rule.ttlInMilliSeconds, 0);
> });
>
> - test('global', function() {
> - var rule = new Rule({ regex: /./, ttlInMilliSeconds: null },
> - { ttlInMilliSeconds: 10 });
> - assert.equal(rule.ttlInMilliSeconds, 10);
> - });
> -
> - test('local', function() {
> - var rule = new Rule({ regex: /./, ttlInMilliSeconds: 20 },
> - { ttlInMilliSeconds: 10 });
> + test('specified', function() {
> + var rule = new Rule({ regex: /./, ttlInMilliSeconds: 20 });
> assert.equal(rule.ttlInMilliSeconds, 20);
> });
> });
>
> Deleted: test/response-cache/cache.test.js (+0 -136) 100644
> ===================================================================
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L0>
> 1 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L1>
> 2 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L2>
> 3 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L3>
> 4 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L4>
> 5 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L5>
> 6 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L6>
> 7 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L7>
> 8 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L8>
> 9 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L9>
> 10 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L10>
> 11 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L11>
> 12 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L12>
> 13 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L13>
> 14 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L14>
> 15 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L15>
> 16 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L16>
> 17 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L17>
> 18 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L18>
> 19 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L19>
> 20 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L20>
> 21 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L21>
> 22 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L22>
> 23 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L23>
> 24 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L24>
> 25 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L25>
> 26 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L26>
> 27 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L27>
> 28 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L28>
> 29 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L29>
> 30 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L30>
> 31 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L31>
> 32 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L32>
> 33 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L33>
> 34 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L34>
> 35 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L35>
> 36 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L36>
> 37 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L37>
> 38 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L38>
> 39 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L39>
> 40 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L40>
> 41 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L41>
> 42 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L42>
> 43 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L43>
> 44 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L44>
> 45 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L45>
> 46 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L46>
> 47 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L47>
> 48 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L48>
> 49 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L49>
> 50 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L50>
> 51 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L51>
> 52 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L52>
> 53 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L53>
> 54 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L54>
> 55 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L55>
> 56 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L56>
> 57 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L57>
> 58 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L58>
> 59 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L59>
> 60 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L60>
> 61 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L61>
> 62 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L62>
> 63 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L63>
> 64 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L64>
> 65 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L65>
> 66 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L66>
> 67 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L67>
> 68 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L68>
> 69 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L69>
> 70 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L70>
> 71 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L71>
> 72 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L72>
> 73 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L73>
> 74 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L74>
> 75 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L75>
> 76 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L76>
> 77 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L77>
> 78 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L78>
> 79 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L79>
> 80 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L80>
> 81 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L81>
> 82 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L82>
> 83 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L83>
> 84 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L84>
> 85 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L85>
> 86 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L86>
> 87 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L87>
> 88 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L88>
> 89 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L89>
> 90 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L90>
> 91 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L91>
> 92 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L92>
> 93 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L93>
> 94 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L94>
> 95 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L95>
> 96 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L96>
> 97 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L97>
> 98 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L98>
> 99 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L99>
> 100 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L100>
> 101 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L101>
> 102 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L102>
> 103 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L103>
> 104 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L104>
> 105 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L105>
> 106 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L106>
> 107 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L107>
> 108 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L108>
> 109 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L109>
> 110 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L110>
> 111 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L111>
> 112 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L112>
> 113 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L113>
> 114 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L114>
> 115 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L115>
> 116 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L116>
> 117 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L117>
> 118 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L118>
> 119 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L119>
> 120 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L120>
> 121 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L121>
> 122 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L122>
> 123 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L123>
> 124 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L124>
> 125 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L125>
> 126 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L126>
> 127 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L127>
> 128 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L128>
> 129 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L129>
> 130 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L130>
> 131 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L131>
> 132 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L132>
> 133 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L133>
> 134 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L134>
> 135 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L135>
> 136 <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13L136>
>
>
>
> ... <https://github.com/droonga/express-droonga/commit/ab2834c0c07980ae82062f527f1d062459f2604c#L13R-1>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> @@ -1,136 +0,0 @@
> -var assert = require('chai').assert;
> -
> -var Cache = require('../../lib/response-cache/cache');
> -
> -suite('Response Cache', function() {
> - suite('required parameters', function() {
> - test('missing rules', function() {
> - assert.throw(function() {
> - var cache = new Cache({
> - });
> - }, Error);
> - });
> -
> - test('not-array rules', function() {
> - assert.throw(function() {
> - var cache = new Cache({
> - rules: {
> - 'foo' : {
> - ttl: 10
> - }
> - }
> - });
> - }, Error);
> - });
> - });
> -
> - suite('getRule', function() {
> - test('non-GET requests', function() {
> - var cache = new Cache({
> - rules: [
> - { regex: /foo/ }
> - ]
> - });
> - var stubRequest = {
> - method: 'POST'
> - };
> - var rule = cache.getRule(stubRequest);
> - assert.isNull(rule);
> - });
> -
> - test('not mached', function() {
> - var cache = new Cache({
> - rules: [
> - { regex: /foo/ }
> - ]
> - });
> - var stubRequest = {
> - method: 'GET',
> - url: 'bar'
> - };
> - var rule = cache.getRule(stubRequest);
> - assert.isNull(rule);
> - });
> -
> - test('mached to a rule', function() {
> - var cache = new Cache({
> - rules: [
> - { regex: /foo/ }
> - ]
> - });
> - var stubRequest = {
> - method: 'GET',
> - url: 'fooooo'
> - };
> - var rule = cache.getRule(stubRequest);
> - assert.isNotNull(rule);
> - assert.deepEqual(rule.regex, /foo/);
> - });
> -
> - test('mached to multiple rules', function() {
> - var primaryRegex = /foo/;
> - var secondaryRegex = /foobar/;
> - var cache = new Cache({
> - rules: [
> - { regex: primaryRegex },
> - { regex: secondaryRegex },
> - ]
> - });
> - var stubRequest = {
> - method: 'GET',
> - url: 'foobar'
> - };
> - var rule = cache.getRule(stubRequest);
> - assert.isNotNull(rule);
> - assert.deepEqual(rule.regex, primaryRegex);
> - });
> - });
> -
> - suite('statistics', function() {
> - var cache;
> - setup(function() {
> - cache = new Cache({
> - rules: [
> - { regex: /.*/ }
> - ]
> - });
> - });
> -
> - test('nGets', function() {
> - assert.equal(cache.getStatistics().nGets, 0);
> - cache.get('key', function(error, cachedResponse) {
> - });
> - assert.equal(cache.getStatistics().nGets, 1);
> - });
> -
> - test('nHits', function() {
> - cache.set('key', 'value');
> - assert.equal(cache.getStatistics().nHits, 0);
> - cache.get('key', function(error, cachedResponse) {
> - });
> - assert.equal(cache.getStatistics().nHits, 1);
> - });
> -
> - suite('hitRatio', function() {
> - test('0 gets', function() {
> - assert.equal(cache.getStatistics().hitRatio, 0.0);
> - });
> -
> - test('0 hits', function() {
> - cache.get('key', function(error, cachedResponse) {
> - });
> - assert.equal(cache.getStatistics().hitRatio, 0.0);
> - });
> -
> - test('1/2 hits', function() {
> - cache.get('key', function(error, cachedResponse) {
> - });
> - cache.set('key', 'value');
> - cache.get('key', function(error, cachedResponse) {
> - });
> - assert.equal(cache.getStatistics().hitRatio, 50.0);
> - });
> - });
> - });
> -});
> -
>
>
>
> _______________________________________________
> Groonga-commit mailing list
> Groonga-commit �� lists.sourceforge.jp
> http://lists.sourceforge.jp/mailman/listinfo/groonga-commit
>
--
結城 洋志 <YUKI Hiroshi>
E-mail: yuki �� clear-code.com
株式会社クリアコード
〒113-0033 東京都文京区本郷3-27-12
本郷デントビル2階
TEL : 03-6231-7270
FAX : 03-6231-7271
WWW : http://www.clear-code.com/