diff --git a/.github/workflows/cve-scan.yml b/.github/workflows/cve-scan.yml new file mode 100644 index 000000000..72b67d994 --- /dev/null +++ b/.github/workflows/cve-scan.yml @@ -0,0 +1,21 @@ +name: Weekly Trivy Scan + +on: + schedule: + - cron: '0 0 * * 1' # Run every Monday at midnight + workflow_dispatch: + +jobs: + trivy_scan: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Trivy + run: | + curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sudo sh -s -- -b /usr/local/bin v0.56.2 + + - name: Run Trivy scan + run: | + trivy fs --security-checks vuln . \ No newline at end of file diff --git a/.github/workflows/dockerhub.yml b/.github/workflows/dockerhub.yml index 1b0be560c..81c4c022d 100644 --- a/.github/workflows/dockerhub.yml +++ b/.github/workflows/dockerhub.yml @@ -17,6 +17,9 @@ jobs: - name: Check out the repo uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log in to Docker Hub uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a with: @@ -29,19 +32,21 @@ jobs: with: images: dicedb/dicedb - - name: Build and push Docker image + - name: Build and push Docker image (with cache) id: push - uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - + cache-from: type=gha # This tells Buildx to attempt to use the GitHub Actions cache + cache-to: type=gha,mode=max # This stores the generated cache in the GitHub Actions cache + - name: Generate artifact attestation uses: actions/attest-build-provenance@v1 with: subject-name: docker.io/dicedb/dicedb subject-digest: ${{ steps.push.outputs.digest }} - push-to-registry: true + push-to-registry: true \ No newline at end of file diff --git a/.github/workflows/full-test-suite.yml b/.github/workflows/full-test-suite.yml index 7007a4d7c..fe486d978 100644 --- a/.github/workflows/full-test-suite.yml +++ b/.github/workflows/full-test-suite.yml @@ -33,11 +33,19 @@ jobs: uses: actions/setup-go@v5 with: go-version: "1.23.x" + - name: Cache dependencies + uses: actions/cache@v3 + with: # Cache the Go modules + path: | + vendor/ + key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - name: Install dependencies - run: go get . + run: go get -v . # Check if there is any version changes from the cache - name: Build run: make build - name: Run Unit tests run: make unittest - name: Run Integration tests - run: make test + run: make test \ No newline at end of file diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index ce3c57abb..4e06d1e43 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -1,9 +1,15 @@ -name: linter +name: Linter + on: push: - branches: [ master ] + branches: [master] + paths: + - '*.go' + pull_request: - branches: [ master ] + branches: [master] + paths: + - '*.go' permissions: contents: read @@ -22,3 +28,4 @@ jobs: uses: golangci/golangci-lint-action@v6 with: version: v1.60.1 + \ No newline at end of file diff --git a/README.md b/README.md index ccd69c63c..80fec9258 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ DiceDB ![Docs](https://img.shields.io/badge/docs-00A1FF?style=flat-square) discord community -DiceDB is a redis-compliant, in-memory, real-time, and reactive database optimized for modern hardware and for building and scaling truly real-time applications. +DiceDB is a redis-compliant, reactive, scalable, highly available, unified cache optimized for modern hardware. We are looking for Early Design Partners, so, if you want to evaluate DiceDB, [block our calendar](https://cal.com/dicedb-arpit). always up for a chat. @@ -32,7 +32,7 @@ Although DiceDB is a drop-in replacement of Redis, which means almost no learnin ## Get started -### Setting up DiceDB with Dockerc +### Setting up DiceDB with Docker The easiest way to get started with DiceDB is using [Docker](https://www.docker.com/) by running the following command. diff --git a/build_protos.sh b/build_protos.sh new file mode 100644 index 000000000..0a21e13f4 --- /dev/null +++ b/build_protos.sh @@ -0,0 +1 @@ +protoc --go_out=. ./internal/wal/wal.proto \ No newline at end of file diff --git a/config/config.go b/config/config.go index 9809c135f..e866aeab9 100644 --- a/config/config.go +++ b/config/config.go @@ -55,6 +55,11 @@ var ( EnableProfiling = false EnableWatch = true + LogDir = "" + + EnableWAL = true + RestoreFromWAL = false + WALEngine = "sqlite" ) type Config struct { diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index a9c1b31d6..f7dff5a93 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -1,9 +1,9 @@ -DiceDB welcomes your contributions! Whether you're fixing bugs, adding new features, or improving the documentation, your help is valuable. +DiceDB welcomes your contributions! Whether you're fixing bugs, adding new features, or improving the documentation, your help is valuable. To maintain the project's quality and consistency, please follow these guidelines: -- Keep the code consistent: Use the same coding style and conventions throughout the project. -- Keep the git repository consistent: Follow proper git practices to avoid conflicts and ensure a clean history. +- Keep the code consistent: Use the same coding style and conventions throughout the project. +- Keep the git repository consistent: Follow proper git practices to avoid conflicts and ensure a clean history. # Contribution Guidelines diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 4862694d9..89e3468c3 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -26,7 +26,7 @@ export default defineConfig({ // }, { label: "SDK", - autogenerate: { directory: "sdk" }, + autogenerate: { directory: "sdk" }, }, { label: "Connection Protocols", @@ -36,16 +36,6 @@ export default defineConfig({ label: "Commands", autogenerate: { directory: "commands" }, }, - { - label: "Metrics", - items: [ - { - label: "Memtier Benchmark", - link: "https://dicedb.io/metrics/memtier.html", - attrs: { target: "_blank" }, - }, - ], - }, ], }), ], diff --git a/docs/command_docs_template.md b/docs/command_docs_template.md index d370ee71c..20a7ecf06 100644 --- a/docs/command_docs_template.md +++ b/docs/command_docs_template.md @@ -2,6 +2,7 @@ title: description: description here in 2 to 3 lines --- + @@ -15,58 +16,67 @@ description: description here in 2 to 3 lines ## Parameters - -| Parameter | Description | Type | Required | -|-----------|---------------------------------------------------------------------------|---------|----------| -| | | | | -| | | | | -| | | | | + +| Parameter | Description | Type | Required | +| --------- | ----------- | ---- | -------- | +| | | | | +| | | | | +| | | | | ## Return values + -| Condition | Return Value | -|------------------------------------------------|---------------------------------------------------| -| | | -| | | -| | | +| Condition | Return Value | +| --------- | ------------ | +| | | +| | | +| | | ## Behaviour + + - Bullet 1 - Bullet 2 - Bullet 3 ## Errors + + 1. `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 + + ### Basic Usage + ```bash 127.0.0.1:7379> SET foo bar OK ``` + + ### Invalid usage ```bash @@ -81,20 +91,25 @@ OK + ## Best Practices + ## Alternatives -## Notes +## Notes + ## Subcommands + + - **subcommand**: Optional. Available subcommands include: - `subcommand1` : some description of the subcommand. diff --git a/docs/sample_command_docs.md b/docs/sample_command_docs.md index 3fc5d9ecc..bf0c692d9 100644 --- a/docs/sample_command_docs.md +++ b/docs/sample_command_docs.md @@ -2,7 +2,9 @@ title: SET description: The `SET` command in DiceDB is used to set the value of a key. If the key already holds a value, it is overwritten, regardless of its type. This is one of the most fundamental operations in DiceDB as it allows for both creating and updating key-value pairs. --- + + The `SET` command in DiceDB is used to set the value of a key. If the key already holds a value, it is overwritten, regardless of its type. This is one of the most fundamental operations in DiceDB as it allows for both creating and updating key-value pairs. ## Syntax @@ -10,13 +12,16 @@ The `SET` command in DiceDB is used to set the value of a key. If the key alread ```bash SET key value [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL] [NX | XX] ``` + ## Parameters + + | Parameter | Description | Type | Required | -|-----------|---------------------------------------------------------------------------|---------|----------| +| --------- | ------------------------------------------------------------------------- | ------- | -------- | | `key` | The name of the key to be set. | String | Yes | | `value` | The value to be set for the key. | String | Yes | | `EX` | Set the specified expire time, in seconds. | Integer | No | @@ -28,18 +33,21 @@ SET key value [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix | `KEEPTTL` | Retain the time-to-live associated with the key. | None | No | ## Return values + -| Condition | Return Value | -|------------------------------------------------|---------------------------------------------------| -| if key is set successfully | `OK` | -| If `NX` is used and key already exists | `nil` | -| If `XX` is used and key doesn't exist | `nil` | +| Condition | Return Value | +| -------------------------------------- | ------------ | +| if key is set successfully | `OK` | +| If `NX` is used and key already exists | `nil` | +| If `XX` is used and key doesn't exist | `nil` | ## Behaviour + + - If the specified key already exists, the `SET` command will overwrite the existing key-value pair with the new value unless the `NX` option is provided. - If the `NX` option is present, the command will set the key only if it does not already exist. If the key exists, no operation is performed and `nil` is returned. - If the `XX` option is present, the command will set the key only if it already exists. If the key does not exist, no operation is performed and `nil` is returned. @@ -47,8 +55,8 @@ SET key value [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix - When provided, `EX` sets the expiry time in seconds and `PX` sets the expiry time in milliseconds. - The `KEEPTTL` option ensures that the key's existing TTL is retained. - ## Errors + @@ -71,6 +79,7 @@ SET key value [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix ## Example Usage ### Basic Usage + Setting a key `foo` with the value `bar` @@ -79,7 +88,9 @@ Setting a key `foo` with the value `bar` 127.0.0.1:7379> SET foo bar OK ``` + + ### Using expiration time (in seconds) Setting a key `foo` with the value `bar` to expire in 10 seconds @@ -141,6 +152,7 @@ Trying to set key `foo` with both `EX` and `KEEPTTL` will result in an error 127.0.0.1:7379> SET foo bar EX 10 KEEPTTL (error) ERR syntax error ``` + @@ -148,29 +160,41 @@ Trying to set key `foo` with both `EX` and `KEEPTTL` will result in an error + ## Best Practices + + - `Avoid in Production`: Due to its potential to slow down the server, avoid using the `KEYS` command in a production environment. Instead, consider using the `SCAN` command, which is more efficient for large keyspaces. - `Use Specific Patterns`: When using the `KEYS` command, try to use the most specific pattern possible to minimize the number of keys returned and reduce the load on the server. + ## Alternatives + + - `SCAN`: The `SCAN` command is a cursor-based iterator that allows you to incrementally iterate over the keyspace without blocking the server. It is a more efficient alternative to `KEYS` for large datasets. + ## Notes + + - JSONPath expressions allow you to navigate and retrieve specific parts of a JSON document. Ensure that your JSONPath expressions are correctly formatted to avoid errors. By understanding the `JSON.GET` command, you can efficiently retrieve JSON data stored in your DiceDB database, enabling you to build powerful and flexible applications that leverage the capabilities of DiceDB. + ## Subcommands + + - **subcommand**: Optional. Available subcommands include: - `COUNT` : Returns the total number of commands in the DiceDB server. - `GETKEYS` : Returns the keys from the provided command and arguments. diff --git a/docs/src/components/Footer.astro b/docs/src/components/Footer.astro index d6d612aef..3e0bf9fba 100644 --- a/docs/src/components/Footer.astro +++ b/docs/src/components/Footer.astro @@ -41,6 +41,12 @@ import { Github } from "lucide-astro"; > Developers +

+ Blog +

+

+ Releases +

Quickstart Commands

- + Examples

@@ -69,10 +72,7 @@ import { Github } from "lucide-astro"; Examples

- + Real-time Leaderboard

@@ -88,9 +88,7 @@ import { Github } from "lucide-astro"; About Us

-->

- - Contact Us + Contact Us


diff --git a/docs/src/components/Hero.astro b/docs/src/components/Hero.astro index de14d026e..74ffb1fb1 100644 --- a/docs/src/components/Hero.astro +++ b/docs/src/components/Hero.astro @@ -4,31 +4,24 @@ import Dice from "./Dice.astro"; import site from "../data/site.json"; --- -

-
-
-
- - We shipped DiceDB v0.0.4 - - -
- DiceDB Logo -
-
-

Build truly real-time applications

-

- DiceDB is an in-memory, real-time, and reactive database with Redis and SQL support optimized for modern hardware and building real-time applications. +

+
+
+
+

a super cache;

+

+ DiceDB is a redis-compliant, reactive, scalable, highly available, unified cache optimized for modern hardware + *

-
- +

+ docker run -p 7379:7379 dicedb/dicedb +

+
-

- Want to evaluate and adopt DiceDB at your org? - block our calendar. +

+ * DiceDB is a work in progress; track + roadmap and follow along.

-
-
-
- -
diff --git a/docs/src/components/Nav.astro b/docs/src/components/Nav.astro index ade34a2f5..38f5a671e 100644 --- a/docs/src/components/Nav.astro +++ b/docs/src/components/Nav.astro @@ -36,19 +36,19 @@ import SocialHandlesIcons from "./SocialHandlesIcons.astro"; class={`navbar-item ${currentPage === "benchmarks" && "is-active"}`} href="/benchmarks" > - Benchmarks + Benchmarks - Docs + Docs - Blog + Blog