diff options
| author | alex <[email protected]> | 2026-07-11 11:57:44 +0200 |
|---|---|---|
| committer | alex <[email protected]> | 2026-07-11 11:57:44 +0200 |
| commit | 1470772a00faad4a5b4130e0fe47513e5618e31d (patch) | |
| tree | 981091c3175d1e5a62e8b8be5da4f6838b0b25d2 /pkg/commands/rename.go | |
| parent | c51e7f6d095153fa4d5358216271aeb4ad73ee0c (diff) | |
| download | redis-clone-1470772a00faad4a5b4130e0fe47513e5618e31d.tar.xz redis-clone-1470772a00faad4a5b4130e0fe47513e5618e31d.zip | |
refactored some more commands to work with the new command registry
Diffstat (limited to 'pkg/commands/rename.go')
| -rw-r--r-- | pkg/commands/rename.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/pkg/commands/rename.go b/pkg/commands/rename.go new file mode 100644 index 0000000..6325fd4 --- /dev/null +++ b/pkg/commands/rename.go @@ -0,0 +1,19 @@ +package commands + +import ( + "errors" + "redisClone/pkg/core" +) + +func Rename(args []string, getShard func(k string) *core.Shard) interface{}{ + item, exists := getShard(args[1]).Data[args[1]] + if !exists { + + return errors.New("no such key") + } + + getShard(args[2]).Data[args[2]] = item + delete(getShard(args[1]).Data, args[1]) + + return core.SimpleString("OK") +} |
