From 284995f96baed4ba617385b144f5c9b2c9dadd28 Mon Sep 17 00:00:00 2001 From: DMcP89 Date: Sat, 23 Nov 2024 23:11:22 -0500 Subject: [PATCH 1/2] Created documentation for RENAMENX command --- docs/docs/commands/generic/renamenx.md | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 docs/docs/commands/generic/renamenx.md diff --git a/docs/docs/commands/generic/renamenx.md b/docs/docs/commands/generic/renamenx.md new file mode 100644 index 00000000..168896a8 --- /dev/null +++ b/docs/docs/commands/generic/renamenx.md @@ -0,0 +1,46 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# RENAME + +### Syntax +``` +RENAME key newkey +``` + +### Module +generic + +### Categories +fast +write + +### Description +Renames key to newkey. If newkey already exists, it is overwritten. If key does not exist, an error is returned. + +### Examples + + + + Rename the key `mykey` to `newkey`: + ```go + db, err := sugardb.NewSugarDB() + if err != nil { + log.Fatal(err) + } + err = db.Rename("mykey", "newkey") + ``` + + + Rename the key `mykey` to `newkey`: + ``` + > RENAME mykey newkey + ``` + + \ No newline at end of file From b9b6e3ee6672dccc806aa812fd5bb7df21b477bf Mon Sep 17 00:00:00 2001 From: DMcP89 Date: Sat, 23 Nov 2024 23:21:12 -0500 Subject: [PATCH 2/2] Updating documentation --- docs/docs/commands/generic/renamenx.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/docs/commands/generic/renamenx.md b/docs/docs/commands/generic/renamenx.md index 168896a8..942945af 100644 --- a/docs/docs/commands/generic/renamenx.md +++ b/docs/docs/commands/generic/renamenx.md @@ -1,11 +1,11 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -# RENAME +# RENAMENX ### Syntax ``` -RENAME key newkey +RENAMENX key newkey ``` ### Module @@ -13,10 +13,11 @@ RENAME key newkey ### Categories fast +keyspace write ### Description -Renames key to newkey. If newkey already exists, it is overwritten. If key does not exist, an error is returned. +Renames the specified key with the new name only if the new name does not already exist. ### Examples @@ -34,13 +35,13 @@ Renames key to newkey. If newkey already exists, it is overwritten. If key does if err != nil { log.Fatal(err) } - err = db.Rename("mykey", "newkey") + err = db.RenameNX("mykey", "newkey") ``` Rename the key `mykey` to `newkey`: ``` - > RENAME mykey newkey + > RENAMENX mykey newkey ``` - \ No newline at end of file +