mirror of
https://github.com/fluencelabs/redis
synced 2025-08-01 00:41:56 +00:00
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:
@@ -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
|
||||
} {}
|
||||
|
Reference in New Issue
Block a user