forked from DiceDB/dice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DiceDB#1537 from DiceDB/arpit-readiness-cli-chat
Splitting documentation into sections.
- Loading branch information
Showing
13 changed files
with
75 additions
and
141 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,30 @@ | ||
--- | ||
title: EXISTS | ||
description: The `EXISTS` command in DiceDB is used to determine if one or more specified keys exist in the database. It returns the number of keys that exist among the specified ones. | ||
description: EXISTS returns the count of keys that exist among the given | ||
--- | ||
|
||
The `EXISTS` command in DiceDB is used to determine if one or more specified keys exist in the database. It returns the number of keys that exist among the specified ones. | ||
<!-- This file is automatically generated. Any modifications made directly to this file | ||
may be overwritten. For more details on how this file is generated and how to use | ||
the related commands, refer to the documentation available in the `internal/cmd/cmd_*.go` files. | ||
--> | ||
|
||
## Syntax | ||
#### Syntax | ||
|
||
```bash | ||
``` | ||
EXISTS key [key ...] | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Description | Type | Required | | ||
| --------- | ------------------------------------------------------------------------------------------ | ------ | -------- | | ||
| `key` | The key(s) to check for existence. One or more keys can be specified, separated by spaces. | String | Yes | | ||
|
||
## Return values | ||
|
||
| Condition | Return Value | | ||
| -------------------------------- | ------------------------------------------------- | | ||
| None of the specified keys exist | `0` | | ||
| One or more specified keys exist | Integer representing the count of keys that exist | | ||
|
||
## Behaviour | ||
|
||
- The `EXISTS` command checks whether the specified keys are present in the database. | ||
- Returns 1 or 0, or for multiple keys returns the count of existing keys. | ||
- The command performs a read-only operation and does not modify the database. | ||
|
||
## Errors | ||
EXISTS command returns the count of keys that exist among the given arguments without modifying them. | ||
|
||
1. `Wrong number of arguments`: | ||
#### Examples | ||
|
||
- Error Message: `(error) ERR wrong number of arguments for 'exists' command` | ||
- Occurs when no key is provided. | ||
|
||
2. `Wrong type of value or key`: | ||
- Error Message: `(error) WRONGTYPE Operation against a key holding the wrong kind of value` | ||
- Occurs when attempting to use the command on a key that contains a non-string value. | ||
|
||
## Example Usage | ||
|
||
### Single Key Check | ||
|
||
Checking if a key `mykey` exists in the database: | ||
|
||
```bash | ||
127.0.0.1:7379> SET mykey "Hello" | ||
OK | ||
127.0.0.1:7379> EXISTS mykey | ||
(integer) 1 | ||
``` | ||
### Multiple Keys Check | ||
|
||
Checking if multiple keys (`key1`, `key2`, `key3`) exist in the database: | ||
|
||
```bash | ||
127.0.0.1:7379> SET key1 "value1" | ||
localhost:7379> SET k1 v1 | ||
OK | ||
127.0.0.1:7379> SET key2 "value2" | ||
localhost:7379> SET k2 v2 | ||
OK | ||
127.0.0.1:7379> EXISTS key1 key2 key3 | ||
(integer) 2 | ||
``` | ||
|
||
In this case, `key1` and `key2` exist, but `key3` does not. | ||
|
||
### Non-Existent Key | ||
|
||
Checking if a non-existent key (`nonExistentKey`) is present in the database: | ||
|
||
```bash | ||
127.0.0.1:7379> EXISTS nonExistentKey | ||
(integer) 0 | ||
``` | ||
|
||
### All Non-Existent Keys | ||
|
||
Checking if all non-existent keys return 0: | ||
|
||
```bash | ||
127.0.0.1:7379> EXISTS nonExistentKey1 nonExistentKey2 | ||
(integer) 0 | ||
``` | ||
|
||
### Empty Command | ||
|
||
Providing no keys should trigger an error: | ||
|
||
```bash | ||
127.0.0.1:7379> EXISTS | ||
(error) ERR wrong number of arguments for 'exists' command | ||
localhost:7379> EXISTS k1 k2 k3 | ||
OK 2 | ||
``` |
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
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