question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple set without any get calls, results in ttl mismatch

See original GitHub issue

Scenario

const cache =  lru();
cache.set("foo", "bar");
// wait until TTL has passed
cache.set("foo", "baz");
const result = cache.get("foo");
console.log(typeof result === "undefined");

I do not expect the result to be “undefined”, but rather expect it to be the “baz” value. The second set() should IMO update the expiry property.

Failing test:

exports.multiSetWithTTL = {
	setUp: function (done) {
		this.cache = lru(4, 10);
		done();
	},
	test: function (test) {
		this.cache.set("foo", "bar");
		setTimeout(function(){
			this.cache.set("foo", "baz");
			test.equal(this.cache.get("foo"), "baz", "should return baz");
			test.done();
		}.bind(this), 11);
	}
};

Want a PR for this? This fix would require a breaking change? If this behaviour is expected, it should be documented in the README.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sveisveicommented, Jun 8, 2020

Thanx again.

1reaction
avoidworkcommented, Jun 6, 2020

i can likely land this corrected implementation over the weekend or on monday.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automatic persisted queries - Apollo GraphQL Docs
Apollo Server supports APQ without any additional configuration. ... Many CDNs only cache GET requests, but many GraphQL queries are too long to...
Read more >
IP Routing: OSPF Configuration Guide - Cisco
Configuring OSPF TTL Security Check and OSPF Graceful Shutdown. This module describes configuration tasks to configure various options ...
Read more >
Caching challenges and strategies - AWS
Improving latency and availability with caching, while avoiding the modal behavior they can introduce.
Read more >
Common Errors and Solutions | CockroachDB Docs
This message indicates that the cluster is using TLS encryption to protect network communication, and the client is trying to open a connection...
Read more >
What is DNS TTL + Best Practices - Varonis
For example, if the DNS TTL is set to 1800 seconds (30 mins), ... that DNS site will receive a cached version of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found