Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 redis 构建排行榜实现。
我的问题是,如果 ZINCRBY 是一个原子操作,可以在没有单独的互斥锁或多线程环境中使用的情况下使用吗?
ZINCRBY的文档没有提到任何关于原子实现的内容,就像INCR 的文档对 INCR、INCRBY 和 DECR 所做的那样
多谢!
是的,ZINCRBY 是原子的。不需要外部同步。
Redis 实际上是单线程的。即使两个线程同时向 Redis 发送命令,Redis 也只会按顺序执行它们。