Tim
Tim

Reputation: 2285

are single redis commands executed in isolation?

I'm using Node and Redis.

If I issue a redis.set() command, is there any chance that whilst that is being set, another read can occur with the old value?

Upvotes: 1

Views: 591

Answers (2)

chisophugis
chisophugis

Reputation: 799

No, you will never have that problem. One of the basic virtues of Redis is that it has a tight event loop which executes the commands, so they are naturally atomic.

This page has more on the topic (see subheading "Atomicity"), and about Redis in general.

Upvotes: 4

John Zwinck
John Zwinck

Reputation: 249103

Assuming you're talking about two truly concurrent accesses, one write and one read, there is essentially no meaning to this question. If a write is itself atomic and the value is never seen as anything other than the old or new value, then a reader who reads at "about the same time" as a writer may legitimately see either the old or the new value.

Upvotes: 1

Related Questions