Skip to content
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

[Solves #254] Add support for RANDOMKEY command #1093

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
use internal error constants
  • Loading branch information
xanish committed Nov 17, 2024
commit 5ffff02cb6b2848033a6e55dff38902feed53ef3
1 change: 1 addition & 0 deletions internal/errors/migrated_errors.go
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ var (
ErrOverflow = errors.New("ERR increment or decrement would overflow") // Signifies that an increment or decrement operation would exceed the limits.
ErrSyntax = errors.New("ERR syntax error") // Represents a syntax error in a DiceDB command.
ErrKeyNotFound = errors.New("ERR no such key") // Indicates that the specified key does not exist.
ErrUnableToFetchKeys = errors.New("ERR unable to fetch keys from store") // Indicates that the specified key does not exist.
ErrWrongTypeOperation = errors.New("WRONGTYPE Operation against a key holding the wrong kind of value") // Signals an operation attempted on a key with an incompatible type.
ErrInvalidHyperLogLogKey = errors.New("WRONGTYPE Key is not a valid HyperLogLog string value") // Indicates that a key is not a valid HyperLogLog value.
ErrCorruptedHyperLogLogObject = errors.New("INVALIDOBJ Corrupted HLL object detected") // Signals detection of a corrupted HyperLogLog object.
3 changes: 1 addition & 2 deletions internal/eval/eval.go
Original file line number Diff line number Diff line change
@@ -1371,8 +1371,7 @@ func evalRANDOMKEY(args []string, store *dstore.Store) *EvalResponse {

availKeys, err := store.Keys("*")
if err != nil {
return &EvalResponse{Result: nil,
Error: errors.New(string(diceerrors.NewErrWithMessage("could not fetch keys to extract a random key")))}
return &EvalResponse{Result: nil, Error: diceerrors.ErrUnableToFetchKeys}
}

if len(availKeys) > 0 {