Skip to content

Commit 2baec3c

Browse files
committed
Updated max length
1 parent ddbc625 commit 2baec3c

File tree

11 files changed

+22
-22
lines changed

11 files changed

+22
-22
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Where options are the following:
7777
- `evictionPolicy` : eviction policy is can be any valid cache eviction policy, supported eviction policy are FIFO, LIFO, LRU, MRU
7878
- `maxLength` : max length is a cache max length, max length is a positive integer value. The default value is 250, if the value is 0 then it will not check the max length.
7979
- `ttl` : is cache expires time in milliseconds, the default value is 0 and if value if 0 it will not check the ttl.
80-
- `interval` : interval is the time interval in milliseconds, after every interval all the expired items are automatically removed. Default value is 0 and if value is 0 the it will not removes expired items automatically, but don't worry expired items are treated as missing, and deleted when they are fetched.
80+
- `interval` : interval is the time interval in milliseconds, after every interval all the expired items are automatically removed. Default value is 60000 and if value is 0 the it will not removes expired items automatically, but don't worry expired items are treated as missing, and deleted when they are fetched.
8181
- `enableInterval` : enableInterval is a boolean value that is used to enable and disable the interval, the default value is false and if value is explicitly set false then it will not run the interval even if the interval time is set.
8282

8383
Cachejs support TTL, but it is not a TTL cache, and also does not make strong TTL guarantees. When ttl interval is set, expired items are removed from cache periodically.
@@ -92,7 +92,7 @@ const cache = new Cache({
9292
evictionPolicy: "LRU",
9393
maxLength: 10,
9494
ttl: 100,
95-
interval: 1000,
95+
interval: 60000,
9696
});
9797
```
9898

src/cache.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = class Cache {
88
#config = {
99
evictionPolicy: "LRU",
1010
ttl: 0,
11-
maxLength: 0,
11+
maxLength: 250,
1212
interval: 0,
1313
intervalId: null,
1414
enableInterval: false,
@@ -54,7 +54,7 @@ module.exports = class Cache {
5454

5555
options.evictionPolicy = options.evictionPolicy || "LRU";
5656
options.maxLength =
57-
typeof options.maxLength === "number" ? options.maxLength : 1000;
57+
typeof options.maxLength === "number" ? options.maxLength : 250;
5858
options.ttl = typeof options.ttl === "number" ? options.ttl : 0;
5959
if (
6060
typeof options.interval === "number" &&

src/cache.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default class Cache {
88
#config = {
99
evictionPolicy: "LRU",
1010
ttl: 0,
11-
maxLength: 0,
11+
maxLength: 250,
1212
interval: 0,
1313
intervalId: null,
1414
enableInterval: false,
@@ -54,7 +54,7 @@ export default class Cache {
5454

5555
options.evictionPolicy = options.evictionPolicy || "LRU";
5656
options.maxLength =
57-
typeof options.maxLength === "number" ? options.maxLength : 1000;
57+
typeof options.maxLength === "number" ? options.maxLength : 250;
5858
options.ttl = typeof options.ttl === "number" ? options.ttl : 0;
5959
if (
6060
typeof options.interval === "number" &&

src/fifo.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = class FIFO {
55
#linkedList = null;
66
#cache = null;
77
#ttl = 0;
8-
#maxLength = 0;
8+
#maxLength = 250;
99

1010
constructor(options = {}) {
1111
if (
@@ -32,7 +32,7 @@ module.exports = class FIFO {
3232
}
3333

3434
options.maxLength =
35-
typeof options.maxLength === "number" ? options.maxLength : 1000;
35+
typeof options.maxLength === "number" ? options.maxLength : 250;
3636
options.ttl = typeof options.ttl === "number" ? options.ttl : 0;
3737

3838
this.#linkedList = new LinkedList();

src/fifo.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default class FIFO {
55
#linkedList = null;
66
#cache = null;
77
#ttl = 0;
8-
#maxLength = 0;
8+
#maxLength = 250;
99

1010
constructor(options = {}) {
1111
if (
@@ -32,7 +32,7 @@ export default class FIFO {
3232
}
3333

3434
options.maxLength =
35-
typeof options.maxLength === "number" ? options.maxLength : 1000;
35+
typeof options.maxLength === "number" ? options.maxLength : 250;
3636
options.ttl = typeof options.ttl === "number" ? options.ttl : 0;
3737

3838
this.#linkedList = new LinkedList();

src/lifo.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = class LIFO {
55
#linkedList = null;
66
#cache = null;
77
#ttl = 0;
8-
#maxLength = 0;
8+
#maxLength = 250;
99

1010
constructor(options = {}) {
1111
if (
@@ -32,7 +32,7 @@ module.exports = class LIFO {
3232
}
3333

3434
options.maxLength =
35-
typeof options.maxLength === "number" ? options.maxLength : 1000;
35+
typeof options.maxLength === "number" ? options.maxLength : 250;
3636
options.ttl = typeof options.ttl === "number" ? options.ttl : 0;
3737

3838
this.#linkedList = new LinkedList();

src/lifo.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default class LIFO {
55
#linkedList = null;
66
#cache = null;
77
#ttl = 0;
8-
#maxLength = 0;
8+
#maxLength = 250;
99

1010
constructor(options = {}) {
1111
if (
@@ -32,7 +32,7 @@ export default class LIFO {
3232
}
3333

3434
options.maxLength =
35-
typeof options.maxLength === "number" ? options.maxLength : 1000;
35+
typeof options.maxLength === "number" ? options.maxLength : 250;
3636
options.ttl = typeof options.ttl === "number" ? options.ttl : 0;
3737

3838
this.#linkedList = new LinkedList();

src/lru.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = class LRU {
55
#linkedList = null;
66
#cache = null;
77
#ttl = 0;
8-
#maxLength = 0;
8+
#maxLength = 250;
99

1010
constructor(options = {}) {
1111
if (
@@ -32,7 +32,7 @@ module.exports = class LRU {
3232
}
3333

3434
options.maxLength =
35-
typeof options.maxLength === "number" ? options.maxLength : 1000;
35+
typeof options.maxLength === "number" ? options.maxLength : 250;
3636
options.ttl = typeof options.ttl === "number" ? options.ttl : 0;
3737

3838
this.#linkedList = new LinkedList();

src/lru.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default class LRU {
55
#linkedList = null;
66
#cache = null;
77
#ttl = 0;
8-
#maxLength = 0;
8+
#maxLength = 250;
99

1010
constructor(options = {}) {
1111
if (
@@ -32,7 +32,7 @@ export default class LRU {
3232
}
3333

3434
options.maxLength =
35-
typeof options.maxLength === "number" ? options.maxLength : 1000;
35+
typeof options.maxLength === "number" ? options.maxLength : 250;
3636
options.ttl = typeof options.ttl === "number" ? options.ttl : 0;
3737

3838
this.#linkedList = new LinkedList();

src/mru.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = class MRU {
55
#linkedList = null;
66
#cache = null;
77
#ttl = 0;
8-
#maxLength = 0;
8+
#maxLength = 250;
99

1010
constructor(options = {}) {
1111
if (
@@ -32,7 +32,7 @@ module.exports = class MRU {
3232
}
3333

3434
options.maxLength =
35-
typeof options.maxLength === "number" ? options.maxLength : 1000;
35+
typeof options.maxLength === "number" ? options.maxLength : 250;
3636
options.ttl = typeof options.ttl === "number" ? options.ttl : 0;
3737

3838
this.#linkedList = new LinkedList();

0 commit comments

Comments
 (0)