Skip to content

Commit

Permalink
added missed command docs
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoleStrel committed Nov 2, 2024
1 parent 20e7d4e commit 60e449b
Show file tree
Hide file tree
Showing 10 changed files with 287 additions and 9 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,15 @@ Benchmark script options:
<a name="commands-connection"></a>
## CONNECTION
* [AUTH](https://sugardb.io/docs/commands/connection/auth)
* [ECHO](https://sugardb.io/docs/commands/connection/echo)
* [HELLO](https://sugardb.io/docs/commands/connection/hello)
* [PING](https://sugardb.io/docs/commands/connection/ping)
* [SELECT](https://sugardb.io/docs/commands/connection/select)
* [SWAPDB](https://sugardb.io/docs/commands/connection/swapdb)

<a name="commands-generic"></a>
## GENERIC
* [COPY](https://sugardb.io/docs/commands/generic/copy)
* [DECR](https://sugardb.io/docs/commands/generic/decr)
* [DECRBY](https://sugardb.io/docs/commands/generic/decrby)
* [DEL](https://sugardb.io/docs/commands/generic/del)
Expand All @@ -216,8 +218,9 @@ Benchmark script options:
* [GETEX](https://sugardb.io/docs/commands/generic/get)
* [INCR](https://sugardb.io/docs/commands/generic/incr)
* [INCRBY](https://sugardb.io/docs/commands/generic/incrby)
* [INCRBYFLOAT](https://sugardb.io/docs/commands/generic/incrbyfloat)
* [MGET](https://sugardb.io/docs/commands/generic/mget)
* [MOVE](https://sugardb.io/docs/commands/generic/move) //-----CHECCKKKKKKKKKK
* [MOVE](https://sugardb.io/docs/commands/generic/move)
* [MSET](https://sugardb.io/docs/commands/generic/mset)
* [OBJECTFREQ](https://sugardb.io/docs/commands/generic/objectfreq)
* [OBJECTIDLETIME](https://sugardb.io/docs/commands/generic/objectidletime)
Expand All @@ -226,6 +229,7 @@ Benchmark script options:
* [PEXPIREAT](https://sugardb.io/docs/commands/generic/pexpireat)
* [PEXPIRETIME](https://sugardb.io/docs/commands/generic/pexpiretime)
* [PTTL](https://sugardb.io/docs/commands/generic/pttl)
* [RANDOMKEY](https://sugardb.io/docs/commands/generic/randomkey)
* [RENAME](https://sugardb.io/docs/commands/generic/rename)
* [SET](https://sugardb.io/docs/commands/generic/set)
* [TTL](https://sugardb.io/docs/commands/generic/ttl)
Expand Down Expand Up @@ -325,6 +329,7 @@ Benchmark script options:

<a name="commands-string"></a>
## STRING
* [APPEND](https://sugardb.io/docs/commands/string/append)
* [GETRANGE](https://sugardb.io/docs/commands/string/getrange)
* [SETRANGE](https://sugardb.io/docs/commands/string/setrange)
* [STRLEN](https://sugardb.io/docs/commands/string/strlen)
Expand Down
43 changes: 43 additions & 0 deletions docs/docs/commands/connection/echo.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# ECHO

### Syntax
```
ECHO [message]
```

### Module
<span className="acl-category">connection</span>

### Categories
<span className="acl-category">connection</span>
<span className="acl-category">fast</span>

### Description
Sends a message to the SugarDB server and it returns the same message back.

### Examples

<Tabs
defaultValue="go"
values={[
{ label: 'Go (Embedded)', value: 'go', },
{ label: 'CLI', value: 'cli', },
]}
>
<TabItem value="go">
```go
// Not available in embedded mode.
```
</TabItem>
<TabItem value="cli">
```
Echo with message:
```
> ECHO "Hello, world!"
"Hello, world!"
```
</TabItem>
</Tabs>
85 changes: 85 additions & 0 deletions docs/docs/commands/generic/copy.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# COPY

### Syntax
```
COPY source destination [DB destination-db] [REPLACE]
```

### Module
<span className="acl-category">generic</span>

### Categories
<span className="acl-category">slow</span>
<span className="acl-category">write</span>
<span className="acl-category">keyspace</span>

### Description
Copies the value stored at the source key to the destination key.
Returns 1 if copied and 0 if not copied.
Also returns 0 if the destination key already exists in the database and the REPLACE option is not set.

### Options
- `DB destination-db`: the destination database to copy the key to
- `REPLACE`: replace the destination key if it already exists

### Examples

<Tabs
defaultValue="go"
values={[
{ label: 'Go (Embedded)', value: 'go', },
{ label: 'CLI', value: 'cli', },
]}
>
<TabItem value="go">
The API provides a struct called COPYOptions that wraps these options in a convenient object.
```go
type COPYOptions struct {
Database string
Replace bool
}
```

Copy the value stored at key 'hello' to the new key 'bye'
```go
db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
db.Set("hello", "world")
key = db.Copy("hello", "bye")
```

Copy the value stored at key 'hello' in database 0 and replace the value at key 'bye' in database 1
```go
db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
err := db.SelectDB(1)
ok, err := db.Set("bye", "goodbye")
err := db.SelectDB(0)
ok, err := db.Set("hello", "world")
ret, err = db.Copy("hello", "bye", db.COPYOptions{Database: "1", Replace: true})
```
</TabItem>
<TabItem value="cli">
Copy the value stored at key 'hello' to the key 'bye'
```
> SET "hello" "world"
> COPY "hello" "bye"
```

Copy the value stored at key 'hello' in database 0 and replace the value at key 'bye' in database 1
```
> SELECT 1
> SET "bye" "goodbye"
> SELECT 0
> SET "hello" "world"
> COPY "hello" "bye" DB 1 REPLACE
```
</TabItem>
</Tabs>
50 changes: 50 additions & 0 deletions docs/docs/commands/generic/incrbyfloat.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# INCRBYFLOAT

### Syntax
```
INCRBYFLOAT key increment
```

### Module
<span className="acl-category">generic</span>

### Categories
<span className="acl-category">fast</span>
<span className="acl-category">write</span>

### Description
Increments the floating point number stored at key by increment. If the key does not exist, it is set to 0 before performing
the operation. An error is returned if the key contains a value of the wrong type or contains a string
that can not be represented as a floating point number.

### Options

### Examples

<Tabs
defaultValue="go"
values={[
{ label: 'Go (Embedded)', value: 'go', },
{ label: 'CLI', value: 'cli', },
]}
>
<TabItem value="go">
Increment the value of the key `mykey` by 10.33:
```go
db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
value, err := db.IncrByFloat("mykey", "10.33")
```
</TabItem>
<TabItem value="cli">
Increment the value of the key `mykey` by 10.33:
```
> INCRBYFLOAT mykey 10.33
```
</TabItem>
</Tabs>
47 changes: 47 additions & 0 deletions docs/docs/commands/generic/randomkey.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# RANDOMKEY

### Syntax
```
RANDOMKEY
```

### Module
<span className="acl-category">generic</span>

### Categories
<span className="acl-category">slow</span>
<span className="acl-category">read</span>
<span className="acl-category">keyspace</span>

### Description
Returns a random key from the currently selected database. If no keys are available, an empty string is returned.

### Examples

<Tabs
defaultValue="go"
values={[
{ label: 'Go (Embedded)', value: 'go', },
{ label: 'CLI', value: 'cli', },
]}
>
<TabItem value="go">
Get a random key from the database:
```go
db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
key, err := db.RandomKey()
```
</TabItem>
<TabItem value="cli">
Get a random key from the database:
```
> RANDOMKEY
```
</TabItem>
</Tabs>
48 changes: 48 additions & 0 deletions docs/docs/commands/string/append.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# APPEND

### Syntax
```
APPEND key value
```

### Module
<span className="acl-category">string</span>

### Categories
<span className="acl-category">write</span>
<span className="acl-category">fast</span>
<span className="acl-category">string</span>

### Description
Appends a value to the end of a string. If the doesn't exist, it creates the key with the value (acts as a SET).
Returns the length of the string after the append operation.

### Examples

<Tabs
defaultValue="go"
values={[
{ label: 'Go (Embedded)', value: 'go', },
{ label: 'CLI', value: 'cli', },
]}
>
<TabItem value="go">
Append a value to the end of a string:
```go
db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
len, err := db.Append("key", "value")
```
</TabItem>
<TabItem value="cli">
Append a value to the end of a string:
```
> APPEND "key" "value"
```
</TabItem>
</Tabs>
4 changes: 2 additions & 2 deletions docs/docs/commands/string/getrange.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ GETRANGE key start end
```

### Module
<span className="acl-category">sortedset</span>
<span className="acl-category">string</span>

### Categories
<span className="acl-category">read</span>
<span className="acl-category">slow</span>
<span className="acl-category">sortedset</span>
<span className="acl-category">string</span>

### Description
Return the substring of the string value stored at key. The substring is specified by the start and end indexes.
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/commands/string/setrange.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ SETRANGE key offset value
```

### Module
<span className="acl-category">sortedset</span>
<span className="acl-category">string</span>

### Categories
<span className="acl-category">write</span>
<span className="acl-category">slow</span>
<span className="acl-category">sortedset</span>
<span className="acl-category">string</span>

### Description
Overwrites part of a string value with another by offset. Creates the key if it doesn't exist.
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/commands/string/strlen.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ STRLEN key
```

### Module
<span className="acl-category">sortedset</span>
<span className="acl-category">string</span>

### Categories
<span className="acl-category">fast</span>
<span className="acl-category">read</span>
<span className="acl-category">sortedset</span>
<span className="acl-category">string</span>

### Description
Returns length of the key's value if it's a string.
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/commands/string/substr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ SUBSTR key start end
```

### Module
<span className="acl-category">sortedset</span>
<span className="acl-category">string</span>

### Categories
<span className="acl-category">read</span>
<span className="acl-category">slow</span>
<span className="acl-category">sortedset</span>
<span className="acl-category">string</span>

### Description
Return the substring of the string value stored at key. The substring is specified by the start and end indexes.
Expand Down

0 comments on commit 60e449b

Please sign in to comment.