-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20e7d4e
commit 60e449b
Showing
10 changed files
with
287 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters