REPLACE option for RESTORE.

The REPLACE option deletes an existing key with the same name (if any)
and materializes the new one. The default behavior without RESTORE is to
return an error if a key already exists.
This commit is contained in:
antirez
2012-11-07 10:57:23 +01:00
parent c4b0b6854e
commit e5b5763f56
3 changed files with 33 additions and 4 deletions

View File

@@ -23,6 +23,22 @@ start_server {tags {"dump"}} {
set e
} {*is busy*}
test {RESTORE can overwrite an existing key with REPLACE} {
r set foo bar1
set encoded1 [r dump foo]
r set foo bar2
set encoded2 [r dump foo]
r del foo
r restore foo 0 $encoded1
r restore foo 0 $encoded2 replace
r get foo
} {bar2}
test {RESTORE can detect a syntax error for unrecongized options} {
catch {r restore foo 0 "..." invalid-option} e
set e
} {*syntax*}
test {DUMP of non existing key returns nil} {
r dump nonexisting_key
} {}