Reputation: 29451
From the RENAME
command documentation (emphasis mine):
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.
Why does Redis copy the data and then DEL
it? In my mind, RENAME
could work a bit like moving a file: the data remains where it is, but the pointer to it is updated, making it a very fast operation. Why doesn't Redis work this way?
Upvotes: 3
Views: 487
Reputation: 50022
Read the doc again :) RENAME
doesn't copy anything, but if the target key exists it is DEL
eted - big target to delete == high latency.
Upvotes: 3