Redisはコマンド実行に関して実質的にシングルスレッドであるため、各コマンドはアトミックに実行されます。つまり、完全に実行され、他のクライアントからの介入がありません。このアトミック性は、アトミックな複合コマンドと組み合わせると、Redisをカウンタ、ロック、並行処理に関連した操作で正しく使用するための基礎となります。
シングルスレッド → アトミックコマンド
Redis executes commands ONE AT A TIME (single-threaded command processing):
→ each command runs to completion before the next starts
→ NO two commands interleave → every command is inherently ATOMIC
→ no race conditions WITHIN a single command
→ This simplicity is a feature: predictable, atomic operations without locks.
アトミックカウンタ(主な利点)
INCR page:views
INCRBY downloads 5
