Added command length tests for INCRBY command. Renamed INCRBY key func. Return WRONG_ARG_RESPONSE from key funcs when commands are not the correct length.

This commit is contained in:
Kelvin Mwinuka
2024-06-25 12:28:23 +08:00
parent fe9344d359
commit db0446507e
4 changed files with 41 additions and 35 deletions

View File

@@ -467,12 +467,12 @@ func (server *EchoVault) Decr(key string) (int, error) {
// If the value stored at the key is not an integer, an error is returned.
//
// Parameters:
// - `key` (string): The key whose value is to be incremented.
// - `increment` (int): The amount by which to increment the key's value. This can be a positive or negative integer.
//
// Returns:
// - (int): The new value of the key after the increment operation.
// `key` - string - The key whose value is to be incremented.
//
// `increment` - int - The amount by which to increment the key's value. This can be a positive or negative integer.
//
// Returns: The new value of the key after the increment operation as an integer.
func (server *EchoVault) IncrBy(key string, value string) (int, error) {
// Construct the command
cmd := []string{"INCRBY", key, value}