push
travis-ci
1105 of 2334 relevant lines covered (47.34%)
110.64 hits per line
1 |
'use strict';
|
|
2 |
|
|
3 |
/**
|
|
4 |
* Cache stats. |
|
5 |
* Represents cache statistic |
|
6 |
* @constructor |
|
7 |
*/ |
|
8 |
function CacheStats() { |
6✔ |
9 |
|
|
10 |
var self = this; |
1,764✔ |
11 |
|
|
12 |
self.puts = 0;
|
1,764✔ |
13 |
self.hits = 0;
|
1,764✔ |
14 |
self.misses = 0;
|
1,764✔ |
15 |
self.expirations = 0;
|
1,764✔ |
16 |
self.size = 0;
|
1,764✔ |
17 |
} |
|
18 |
|
|
19 |
/**
|
|
20 |
* |
|
21 |
* @param {boolean} [_new=true] |
|
22 |
*/ |
|
23 |
CacheStats.prototype.put = function (_new) { |
6✔ |
24 |
_new = _new !== false;
|
807✔ |
25 |
this.puts++;
|
807✔ |
26 |
if (_new) {
|
807✔ |
27 |
this.size++;
|
807✔ |
28 |
} |
|
29 |
}; |
|
30 |
|
|
31 |
CacheStats.prototype.hit = function () { |
6✔ |
32 |
this.hits++;
|
× |
33 |
}; |
|
34 |
|
|
35 |
CacheStats.prototype.miss = function (expired) { |
6✔ |
36 |
this.misses++;
|
× |
37 |
if (expired) {
|
× |
38 |
this.expirations++;
|
× |
39 |
} |
|
40 |
}; |
|
41 |
|
|
42 |
CacheStats.prototype.delete = function () { |
6✔ |
43 |
if (this.size > 0) { |
10 only 1084.1 and 1084.6 ✔ |
44 |
this.size--;
|
10 only 1084.1 and 1084.6 ✔ |
45 |
} |
|
46 |
}; |
|
47 |
|
|
48 |
CacheStats.prototype.clear = function () { |
6✔ |
49 |
this.size = 0; |
× |
50 |
}; |
|
51 |
|
|
52 |
module.exports = CacheStats; |
6✔ |