parseBitRange parses the optional start and end indices and the optional BYTE/BIT argument from the command arguments. It returns the parsed indices, the bit mode (BYTE or BIT), and any error encountered during parsing.
(args []string)
| 878 | |
| 879 | // Return the number of keys that were deleted |
| 880 | return redcon.SimpleInt(n), nil |
| 881 | } |
| 882 | |
| 883 | func cmdMSET(m uhaha.Machine, args []string) (interface{}, error) { |
| 884 | // Check if the number of arguments is valid (must be at least 3 and odd) |
| 885 | if len(args) < 3 || (len(args)-1)%2 != 0 { |
| 886 | return nil, uhaha.ErrWrongNumArgs |
| 887 | } |
| 888 | |
| 889 | // Create a slice to hold the key-value pairs |
| 890 | kvPairs := make([]ledis.KVPair, (len(args)-1)/2) |
| 891 | |
| 892 | // Iterate over the arguments and populate the key-value pairs |
| 893 | for i := 1; i < len(args); i += 2 { |
| 894 | kvPairs[(i-1)/2] = ledis.KVPair{ |
| 895 | Key: []byte(args[i]), |
| 896 | Value: []byte(args[i+1]), |
| 897 | } |
| 898 | } |
| 899 | |
| 900 | // Perform the MSET operation |
| 901 | if err := ldb.MSet(kvPairs...); err != nil { |
| 902 | return nil, err |
| 903 | } |
| 904 | |
| 905 | // Return a simple string reply "OK" upon success |
| 906 | return redcon.SimpleString("OK"), nil |
| 907 | } |
| 908 | |
| 909 | func cmdMGET(m uhaha.Machine, args []string) (interface{}, error) { |
| 910 | // Check the number of arguments; at least one key is required |
| 911 | if len(args) < 2 { |
| 912 | return nil, uhaha.ErrWrongNumArgs |
| 913 | } |
| 914 | |
| 915 | // Extract all keys from the arguments |
| 916 | keys := make([][]byte, len(args)-1) |
| 917 | for i := 1; i < len(args); i++ { |