为什么 Redis RENAME 会造成高延迟?
Why can Redis RENAME cause high latency?
来自 RENAME
command documentation(强调我的):
Renames key to newkey. It returns an error when the source and destination names are the same, or when key does not exist. If newkey already exists it is overwritten, when this happens RENAME executes an implicit DEL operation, so if the deleted key contains a very big value it may cause high latency even if RENAME itself is usually a constant-time operation.
为什么Redis先复制数据然后DEL
呢?在我看来,RENAME
的工作方式有点像移动文件:数据保留在原处,但指向它的指针会更新,从而使其成为一个非常快速的操作。为什么 Redis 不是这样工作的?
再次阅读文档 :) RENAME
不复制任何内容,但如果目标密钥存在,它会被 DEL
eted - 要删除的大目标 == 高延迟。
来自 RENAME
command documentation(强调我的):
Renames key to newkey. It returns an error when the source and destination names are the same, or when key does not exist. If newkey already exists it is overwritten, when this happens RENAME executes an implicit DEL operation, so if the deleted key contains a very big value it may cause high latency even if RENAME itself is usually a constant-time operation.
为什么Redis先复制数据然后DEL
呢?在我看来,RENAME
的工作方式有点像移动文件:数据保留在原处,但指向它的指针会更新,从而使其成为一个非常快速的操作。为什么 Redis 不是这样工作的?
再次阅读文档 :) RENAME
不复制任何内容,但如果目标密钥存在,它会被 DEL
eted - 要删除的大目标 == 高延迟。