Skip to content

Commit

Permalink
Adding a simple test to show how resetTtl should be used for #134
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Oct 4, 2023
1 parent 8ccd082 commit 0c1f7c3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/lru.js
Expand Up @@ -268,6 +268,19 @@ describe("Testing functionality", function () {
}, 11);
});

it("It expires records which reset the TTL on set()", function (done) {
this.cache = lru(1, 250, true);
this.cache.set(this.items[0], false);
setTimeout(() => {
this.cache.set(this.items[0], false);
setTimeout(() => {
const record = this.cache.get(this.items[0]);
assert.strictEqual(record, undefined, "Should be a 'undefined'");
done();
}, 255);
}, 5);
});

it("It handle mid-deletes", function (done) {
this.cache = lru(3);
this.cache.set(this.items[0], false);
Expand Down

0 comments on commit 0c1f7c3

Please sign in to comment.