-
Notifications
You must be signed in to change notification settings - Fork 583
feat: Add DELPREFIX to delete keys by prefix #2828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
frHimanshu
wants to merge
27
commits into
apache:unstable
Choose a base branch
from
frHimanshu:unstable
base: unstable
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 5 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
4514d5f
Update cmd_key.cc
frHimanshu efa8911
Update commander.cc
frHimanshu a144d25
ommander.cc
frHimanshu 513d33f
cmd_key.cc
frHimanshu a503e27
Fixes
frHimanshu f3604d3
Update cmd_key.cc
frHimanshu 6215660
Delete tests/persistence directory
frHimanshu 8a9d566
Delete tests/test_helper.tcl
frHimanshu 82e19a0
Create cmd_delprefix_test.go
frHimanshu 67e54f9
Attempt 3
frHimanshu a095125
Fixes
frHimanshu ebeb166
Update cmd_delprefix_test.go
frHimanshu 5da5b6a
Update cmd_key.cc
frHimanshu a24af6f
Original go.mod
frHimanshu 42fcd7f
Update cmd_key.cc
frHimanshu f413a5b
Update cmd_delprefix_test.go
frHimanshu 83c2394
Update cmd_delprefix_test.go
frHimanshu d8fa88d
Update cmd_key.cc
frHimanshu 5ff609d
Update cmd_key.cc
frHimanshu f979cbd
Update cmd_key.cc
frHimanshu 8ca8b57
Update redis_db.cc
frHimanshu 49e2222
Update redis_db.h
frHimanshu 5dd9fdd
Delete tests/gocase/integration/cli/cmd_delprefix_test.go
frHimanshu 23d0f3c
Create cmd_delprefix_test.go
frHimanshu 804922b
Update cmd_delprefix_test.go
frHimanshu 57cb21d
Merge branch 'unstable' into unstable
aleksraiden 0c71db3
Merge branch 'unstable' into unstable
frHimanshu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
frHimanshu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or 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 @@ | ||
| source tests/includes/init-tests.tcl | ||
|
|
||
| start_server {tags {"delprefix"}} { | ||
| r flushdb | ||
|
|
||
| # Adding keys with different prefixes | ||
| r set user:1 "Alice" | ||
| r set user:2 "Bob" | ||
| r set order:1 "Order123" | ||
| r set order:2 "Order456" | ||
| r set random "SomeValue" | ||
|
|
||
| # Ensure the keys exist | ||
| assert_equal "Alice" [r get user:1] | ||
| assert_equal "Bob" [r get user:2] | ||
| assert_equal "Order123" [r get order:1] | ||
| assert_equal "Order456" [r get order:2] | ||
| assert_equal "SomeValue" [r get random] | ||
|
|
||
| # Delete keys with prefix "user:" | ||
| assert_equal 2 [r delprefix user:] | ||
|
|
||
| # Ensure the correct keys were deleted | ||
| assert_equal {nil} [r get user:1] | ||
| assert_equal {nil} [r get user:2] | ||
| assert_equal "Order123" [r get order:1] | ||
| assert_equal "Order456" [r get order:2] | ||
| assert_equal "SomeValue" [r get random] | ||
|
|
||
| # Delete keys with prefix "order:" | ||
| assert_equal 2 [r delprefix order:] | ||
|
|
||
| # Ensure the correct keys were deleted | ||
| assert_equal {nil} [r get order:1] | ||
| assert_equal {nil} [r get order:2] | ||
| assert_equal "SomeValue" [r get random] | ||
|
|
||
| # Delete a non-existent prefix | ||
| assert_equal 0 [r delprefix nonexisting:] | ||
|
|
||
| # Ensure "random" key still exists | ||
| assert_equal "SomeValue" [r get random] | ||
| } |
This file contains hidden or 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 @@ | ||
| #!/usr/bin/env tclsh | ||
|
|
||
| # Basic test helper for Kvrocks | ||
| set ::test_server "127.0.0.1" | ||
| set ::test_port 6666 | ||
| set ::kvrocks_path "../src/kvrocks" | ||
| set ::kvrocks_conf "../kvrocks.conf" | ||
|
|
||
| proc start_kvrocks {} { | ||
| global test_server test_port kvrocks_path kvrocks_conf | ||
| puts "Starting Kvrocks on $test_server:$test_port..." | ||
| if {[catch {exec $kvrocks_path -c $kvrocks_conf &} result]} { | ||
| puts "Error starting Kvrocks: $result" | ||
| exit 1 | ||
| } | ||
| after 2000 ;# Wait for Kvrocks to start | ||
| } | ||
|
|
||
| proc stop_kvrocks {} { | ||
| puts "Stopping Kvrocks..." | ||
| if {[catch {exec pkill -f kvrocks} result]} { | ||
| puts "Error stopping Kvrocks: $result" | ||
| exit 1 | ||
| } | ||
| after 1000 | ||
| } | ||
|
|
||
| proc run_test {test_script} { | ||
| start_kvrocks | ||
| puts "Running test: $test_script" | ||
| if {[catch {source $test_script} result]} { | ||
| puts "Error running test script: $result" | ||
| stop_kvrocks | ||
| exit 1 | ||
| } | ||
| stop_kvrocks | ||
| } | ||
|
|
||
| if {[llength $argv] == 2 && [lindex $argv 0] eq "--single"} { | ||
| run_test [lindex $argv 1] | ||
| } else { | ||
| puts "Usage: ./test_helper.tcl --single tests/<your_test_script>.tcl" | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.