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.
Migrating ('HLEN', 'HSTRLEN', 'HSCAN') DiceDB#1024 (DiceDB#1162)
* add migration & unit tests * fix : lint * chore : remove comments * test : add http integration tests * test : add websocket integration tests * test : add resp integration tests * chore : cleanup merge conflict * docs : add HSTRLEN documentation * fix : update store_eval return values * chore : fix lint * docs : cleanup HLEN/HSCAN/HSTRLEN docs * test : add missed async testcases to resp * fixed linting issues and conflicts: to speed up the process. --------- Co-authored-by: Ashwin Kulkarni <[email protected]>
- Loading branch information
1 parent
f3a69b8
commit 12616de
Showing
21 changed files
with
1,238 additions
and
429 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
title: HSTRLEN | ||
description: Documentation for the DiceDB command HSTRLEN | ||
--- | ||
|
||
The `HSTRLEN` command in DiceDB is used to obtain the string length of value associated with field in the hash stored at a specified key. | ||
|
||
## Syntax | ||
|
||
``` | ||
HSTRLEN key field | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Description | Type | Required | | ||
|-----------------|------------------------------------------------------------------------------------------|---------|----------| | ||
| `key` | The key of the hash, which consists of the field whose string length you want to obtain | String | Yes | | ||
| `field` | The field present in the hash whose length you want to obtain | String | Yes | | ||
|
||
## Return Value | ||
|
||
| Condition | Return Value | | ||
|------------------------------------------------|---------------------------------------------------| | ||
| If specified key and field exists | string length | | ||
| If key doesn't exist | `0` | | ||
| If field doesn't exist | `0` | | ||
|
||
## Behaviour | ||
|
||
- DiceDB checks if the specified key exists. | ||
- If the key exists, is associated with a hash and specified field exists in the hash, DiceDB returns the string length of value associated with specified field in the hash. | ||
- If the key does not exist, DiceDB returns `0`. | ||
- If the key exists and specified field does not exist in the key, DiceDB returns `0`. | ||
|
||
## Errors | ||
|
||
1. `Wrong type of 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-hash value. | ||
|
||
2. `Wrong number of arguments`: | ||
|
||
- Error Message: `(error) -ERR wrong number of arguments for 'hstrlen' command` | ||
- Occurs if key or field isn't specified in the command. | ||
|
||
## Example Usage | ||
|
||
### Basic Usage | ||
Creating hash `myhash` with two fields `field1` and `field2`. Getting string length of value in `field1`. | ||
|
||
```DiceDB | ||
> HSET myhash field1 "helloworld" field2 "value2" | ||
(integer) 1 | ||
> HSTRLEN myhash field1 | ||
(integer) 10 | ||
``` | ||
|
||
### Invalid Usage on non-existent key | ||
Getting string length from a non-existent key `nonExistentHash`. | ||
|
||
```DiceDB | ||
> HSTRLEN nonExistentHash field1 | ||
(integer) 0 | ||
``` | ||
|
||
### Invalid Usage on non-hash key | ||
Getting string length from a key `mystring` associated with a non-hash type. | ||
|
||
```DiceDB | ||
> SET mystring "This is a string" | ||
OK | ||
> HSTRLEN mystring field1 | ||
(error) WRONGTYPE Operation against a key holding the wrong kind of value | ||
``` | ||
|
||
## Notes | ||
|
||
- The `HSTRLEN` command has a constant-time operation, meaning its execution time is O(1), regardless of the number of fields in the hash. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.