Skip to content

Simple support for DUMP and RESTORE #405

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

alyssaruth
Copy link
Contributor

Closes #401

Simple implementation for DUMP and RESTORE which just supports string keys:

  • Attempting to dump a different key type will produce WRONGTYPE Operation against a key holding the wrong kind of value
  • For RESTORE I've implemented the REPLACE and ABSTTL optional flags, but not IDLETIME or FREQ (wasn't immediately obvious to me what these were 🤷‍♀️ )

I have also:

  • Renamed the existing Dump to DebugDump to avoid confusion
  • Extracted constants for the various key types
  • Collected common validation into validCMD and plugged it in for all the existing generic commands. Happy to do this for the remainder as well if the approach looks good to you 😄

@alicebob
Copy link
Owner

alicebob commented May 19, 2025 via email

@alicebob
Copy link
Owner

alicebob commented Jun 2, 2025

(not forgotten, just busy)

@alicebob alicebob mentioned this pull request Jun 4, 2025
@@ -8,13 +8,7 @@ import (

// Command 'INFO' from https://redis.io/commands/info/
func (m *Miniredis) cmdInfo(c *server.Peer, cmd string, args []string) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one and cmdSelect don't use handleAuth, but with isValidCMD they now do. That looks like it shouldn't change. Otherwise it looks like a nice change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these were using isValidCMD before my change, I just moved the args validation into it (no auth behaviour has changed here).

In any case, I've tested locally with a dockerised redis and these two commands do produce auth errors, so I think the current code is correct:

$ docker run -d --name redis -p 6379:6379 redis:6.2.7 --requirepass "SUPER_SECRET_PASSWORD"
$ docker exec -it redis redis-cli
127.0.0.1:6379> info
NOAUTH Authentication required.
127.0.0.1:6379> select 0
(error) NOAUTH Authentication required.
127.0.0.1:6379> 

@alicebob
Copy link
Owner

alicebob commented Jun 4, 2025

Looks good! I merged the first commit to master, since that was an easy one.

Renamed the existing Dump to DebugDump to avoid confusion

I don't think we can do that, it changes existing code.

Copy link
Contributor Author

@alyssaruth alyssaruth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can do that, it changes existing code.

Do you mean because it would be a breaking change? The thing that prompted me to change it was that otherwise the existing unit tests for this debug feature clashed with the TestDump that I wanted to write (for the actual redis feature). I could just rename the test suite but thought renaming it to something else was a good change anyway - to avoid anyone confusing it with the Redis command. Happy to revert that though and just rename the tests if you feel strongly!

@@ -8,13 +8,7 @@ import (

// Command 'INFO' from https://redis.io/commands/info/
func (m *Miniredis) cmdInfo(c *server.Peer, cmd string, args []string) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these were using isValidCMD before my change, I just moved the args validation into it (no auth behaviour has changed here).

In any case, I've tested locally with a dockerised redis and these two commands do produce auth errors, so I think the current code is correct:

$ docker run -d --name redis -p 6379:6379 redis:6.2.7 --requirepass "SUPER_SECRET_PASSWORD"
$ docker exec -it redis redis-cli
127.0.0.1:6379> info
NOAUTH Authentication required.
127.0.0.1:6379> select 0
(error) NOAUTH Authentication required.
127.0.0.1:6379> 

@alicebob
Copy link
Owner

alicebob commented Jun 4, 2025

thanks for your replies! I'll get back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simple support for Dump / Restore
2 participants