Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,33 @@ func init() {
var Config *DiceDBConfig

type DiceDBConfig struct {
Host string `mapstructure:"host" default:"0.0.0.0" description:"the host address to bind to"`
Port int `mapstructure:"port" default:"7379" description:"the port to bind to"`

Username string `mapstructure:"username" default:"dicedb" description:"the username to use for authentication"`
Password string `mapstructure:"password" default:"" description:"the password to use for authentication"`

LogLevel string `mapstructure:"log-level" default:"info" description:"the log level"`

EnableWatch bool `mapstructure:"enable-watch" default:"false" description:"enable support for .WATCH commands and real-time reactivity"`
MaxClients int `mapstructure:"max-clients" default:"20000" description:"the maximum number of clients to accept"`
NumShards int `mapstructure:"num-shards" default:"-1" description:"number of shards to create. defaults to number of cores"`

Engine string `mapstructure:"engine" default:"ironhawk" description:"the engine to use, values: ironhawk"`

EnableWAL bool `mapstructure:"enable-wal" default:"false" description:"enable write-ahead logging"`
WALDir string `mapstructure:"wal-dir" default:"/var/log/dicedb" description:"the directory to store WAL segments"`
WALMode string `mapstructure:"wal-mode" default:"buffered" description:"wal mode to use, values: buffered, unbuffered"`
WALWriteMode string `mapstructure:"wal-write-mode" default:"default" description:"wal file write mode to use, values: default, fsync"`
WALBufferSizeMB int `mapstructure:"wal-buffer-size-mb" default:"1" description:"the size of the wal write buffer in megabytes"`
WALRotationMode string `mapstructure:"wal-rotation-mode" default:"segment-size" description:"wal rotation mode to use, values: segment-size, time"`
WALMaxSegmentSizeMB int `mapstructure:"wal-max-segment-size-mb" default:"16" description:"the maximum size of a wal segment file in megabytes before rotation"`
WALMaxSegmentRotationTimeSec int `mapstructure:"wal-max-segment-rotation-time-sec" default:"60" description:"the time interval (in seconds) after which wal a segment is rotated"`
WALBufferSyncIntervalMillis int `mapstructure:"wal-buffer-sync-interval-ms" default:"200" description:"the interval (in milliseconds) at which the wal write buffer is synced to disk"`
WALRetentionMode string `mapstructure:"wal-retention-mode" default:"num-segments" description:"the new horizon for wal segment post cleanup. values: num-segments, time, checkpoint"`
WALMaxSegmentCount int `mapstructure:"wal-max-segment-count" default:"10" description:"the maximum number of segments to retain, if the retention mode is 'num-segments'"`
WALMaxSegmentRetentionDurationSec int `mapstructure:"wal-max-segment-retention-duration-sec" default:"600" description:"the maximum duration (in seconds) for wal segments retention"`
WALRecoveryMode string `mapstructure:"wal-recovery-mode" default:"strict" description:"wal recovery mode in case of a corruption, values: strict, truncate, ignore"`
Host string `mapstructure:"host" default:"0.0.0.0" description:"The host address to bind to"`
Port int `mapstructure:"port" default:"7379" description:"The port to bind to"`

Username string `mapstructure:"username" default:"dicedb" description:"The username to use for authentication"`
Password string `mapstructure:"password" default:"" description:"The password to use for authentication"`

LogLevel string `mapstructure:"log-level" default:"info" description:"The log level"`

EnableWatch bool `mapstructure:"enable-watch" default:"false" description:"Enable support for .WATCH commands and real-time reactivity"`
MaxClients int `mapstructure:"max-clients" default:"20000" description:"The maximum number of clients to accept"`
NumShards int `mapstructure:"num-shards" default:"-1" description:"Number of shards to create. defaults to number of cores"`

Engine string `mapstructure:"engine" default:"ironhawk" description:"The engine to use" values:"ironhawk"`

EnableWAL bool `mapstructure:"enable-wal" default:"false" description:"Enable write-ahead logging"`
WALDir string `mapstructure:"wal-dir" default:"/var/log/dicedb" description:"The directory to store WAL segments"`
WALMode string `mapstructure:"wal-mode" default:"buffered" description:"WAL mode to use" values:"buffered, unbuffered"`
WALWriteMode string `mapstructure:"wal-write-mode" default:"default" description:"WAL write mode to use" values:"default, fsync"`
WALBufferSizeMB int `mapstructure:"wal-buffer-size-mb" default:"1" description:"The size of the WAL write buffer in megabytes"`
WALRotationMode string `mapstructure:"wal-rotation-mode" default:"segment-size" description:"WAL rotation mode to use" values:"segment-size, time"`
WALMaxSegmentSizeMB int `mapstructure:"wal-max-segment-size-mb" default:"16" description:"The maximum size of a WAL segment file in megabytes before rotation"`
WALMaxSegmentRotationTimeSec int `mapstructure:"wal-max-segment-rotation-time-sec" default:"60" description:"The time interval (in seconds) after which WAL a segment is rotated"`
WALBufferSyncIntervalMillis int `mapstructure:"wal-buffer-sync-interval-ms" default:"200" description:"The interval (in milliseconds) at which The WAL write buffer is synced to disk"`
WALRetentionMode string `mapstructure:"wal-retention-mode" default:"num-segments" description:"The new horizon for WAL segment post cleanup" values:"num-segments, time, checkpoint"`
WALMaxSegmentCount int `mapstructure:"wal-max-segment-count" default:"10" description:"The maximum number of segments to retain, if the retention mode is 'num-segments'"`
WALMaxSegmentRetentionDurationSec int `mapstructure:"wal-max-segment-retention-duration-sec" default:"600" description:"The maximum duration (in seconds) for WAL segments retention"`
WALRecoveryMode string `mapstructure:"wal-recovery-mode" default:"strict" description:"WAL recovery mode in case of a corruption" values:"strict, truncate, ignore"`
}

func Load(flags *pflag.FlagSet) {
Expand Down
4 changes: 4 additions & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export default defineConfig({
label: "Get started",
autogenerate: { directory: "get-started" },
},
{
label: "Server Configurations",
autogenerate: { directory: "server-configs" },
},
{
label: "SDK",
autogenerate: { directory: "sdk" },
Expand Down
34 changes: 34 additions & 0 deletions docs/src/content/docs/commands/GETSET.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: GETSET
description: GETSET sets the value for the key and returns the old value
---

<!-- 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

```
GETSET key value
```


GETSET sets the value for the key and returns the old value.

The command returns (nil) if the key does not exist.


#### Examples

```

localhost:7379> SET k1 v1
OK OK
localhost:7379> GETSET k1 v2
OK v1
localhost:7379> GET k1
OK v2

```
4 changes: 3 additions & 1 deletion docs/src/content/docs/commands/HANDSHAKE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ description: HANDSHAKE tells the server the purpose of the connection
HANDSHAKE client_id execution_mode
```


HANDSHAKE is used to tell the DiceDB server the purpose of the connection. It
registers the client_id and execution_mode.

Expand All @@ -27,12 +28,13 @@ The execution_mode is the mode of the connection, it can be one of the following

If you use DiceDB SDK or CLI then this HANDSHAKE command is automatically sent when the connection is established
or when you establish a subscription.


#### Examples

```

localhost:7379> HANDSHAKE 4c9d0411-6b28-4ee5-b78a-e7e258afa52f command
OK OK

```
43 changes: 43 additions & 0 deletions docs/src/content/docs/commands/HGET.WATCH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: HGET.WATCH
description: HGET.WATCH creates a query subscription over the HGET command
---

<!-- 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

```
HGET.WATCH key field
```


HGET.WATCH creates a query subscription over the HGET command. The client invoking the command
will receive the output of the HGET command (not just the notification) whenever the value against
the key and field is updated.

You can update the key in any other client. The HGET.WATCH client will receive the updated value.


#### Examples

```

client1:7379> HSET k1 f1 v1
OK 1
client1:7379> HGET.WATCH k1 f1
entered the watch mode for HGET.WATCH k1 f1


client2:7379> HSET k1 f1 v2
OK 0


client1:7379> ...
entered the watch mode for HGET.WATCH k1 f1
OK [fingerprint=3432795955] v2

```
50 changes: 50 additions & 0 deletions docs/src/content/docs/commands/KEYS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: KEYS
description: KEYS returns all keys matching the pattern
---

<!-- 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

```
KEYS pattern
```


KEYS returns all keys matching the pattern.

The pattern can contain the following special characters to match multiple keys.
Supports glob-style patterns:
- *: matches any sequence of characters
- ?: matches any single character

#### Examples

```

localhost:7379> SET k1 v1
OK OK
localhost:7379> SET k2 v2
OK OK
localhost:7379> SET k33 v33
OK OK
localhost:7379> KEYS k?
OK
1) "k1"
2) "k2"
localhost:7379> KEYS k*
OK
1) "k1"
2) "k2"
3) "k33"
localhost:7379> KEYS *
OK
1) "k1"
2) "k2"
3) "k33"

```
2 changes: 1 addition & 1 deletion docs/src/content/docs/commands/SET.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: SET puts or updates an existing <key, value> pair
#### Syntax

```
SET key value [EX seconds] [PX milliseconds] [EXAT timestamp] [PXAT timestamp] [XX] [NX] [KEEPTTL]
SET key value [EX seconds] [PX milliseconds] [EXAT timestamp] [PXAT timestamp] [XX] [NX] [KEEPTTL] [GET]
```


Expand Down
47 changes: 47 additions & 0 deletions docs/src/content/docs/commands/ZADD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: ZADD
description: ZADD adds all the specified members with the specified scores to the sorted set stored at key
---

<!-- 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

```
ZADD key [NX | XX] [GT | LT] [CH] [INCR] score member [score member...]
```


ZADD adds all the specified members with the specified scores to the sorted set stored at key

- NX: Only add new elements and do not update existing elements
- XX: Only update existing elements and do not add new elements
- GT: Only add new elements if the score is greater than the existing score
- LT: Only add new elements if the score is less than the existing score
- CH: Modify the return value from the number of new elements added to the total number of elements changed
- INCR: When this option is specified, the scores provided are treated as increments to the score of the existing elements

The command by default returns the number of elements added to the sorted set.


#### Examples

```

localhost:7379> ZADD users 10 u1
OK 1
localhost:7379> ZADD users 5 u2
OK 1
localhost:7379> ZADD users 15 u3
OK 1
localhost:7379> ZADD users 12 u4
OK 1
localhost:7379> ZADD users 10 u1
OK 0
localhost:7379> ZADD users CH 11 u1
OK 1

```
47 changes: 47 additions & 0 deletions docs/src/content/docs/commands/ZCOUNT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: ZCOUNT
description: ZCOUNT counts the number of members in a sorted set between min and max (both inclusive)
---

<!-- 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

```
ZCOUNT key min max
```


ZCOUNT counts the number of members in a sorted set between min and max (both inclusive)

If you want to use unbounded ranges, use -inf and +inf for min and max respectively.
The command returns the count of members in a sorted set between min and max (both inclusive). Returns 0 if the key does not exist.


#### Examples

```

localhost:7379> ZADD k 10 k1
OK 1
localhost:7379> ZADD k 20 k2
OK 1
localhost:7379> ZADD k 30 k3
OK 1
localhost:7379> ZCOUNT k 10 20
OK 2
localhost:7379> ZCOUNT k 10 30
OK 3
localhost:7379> ZCOUNT k 10 40
OK 3
localhost:7379> ZCOUNT k 1 2
OK 0
localhost:7379> ZCOUNT k -inf +inf
OK 3
localhost:7379> ZCOUNT k 10 10
OK 1

```
31 changes: 31 additions & 0 deletions docs/src/content/docs/commands/ZRANGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: ZRANGE
description: Returns the specified range of elements in the sorted set stored at <key>.
---

<!-- 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

```
ZRANGE key start stop [REV] [WITHSCORES]
```


Returns the specified range of elements in the sorted set stored at key.
The elements are considered to be ordered from the lowest to the highest score.
Both start and stop are 0-based indexes, where 0 is the first element, 1 is the next element and so on.
These indexes can also be negative numbers indicating offsets from the end of the sorted set, with -1 being the last element of the sorted set, -2 the penultimate element and so on.
Returns the specified range of elements in the sorted set.


#### Examples

```

localhost:7379> ZRANGE mySortedSet 1 3

```
Loading