cmdSETRANGE overwrites part of the string stored at key, starting at the specified offset, for the entire length of the value. If the offset is larger than the current length of the string, the string is padded with zero-bytes to make offset fit. Non-existing keys are treated as empty strings.
(m uhaha.Machine, args []string)
| 127 | // cmdSETRANGE overwrites part of the string stored at key, starting at the specified offset, |
| 128 | // for the entire length of the value. If the offset is larger than the current length of the string, |
| 129 | // the string is padded with zero-bytes to make offset fit. Non-existing keys are treated as empty strings. |
| 130 | func cmdSETRANGE(m uhaha.Machine, args []string) (interface{}, error) { |
| 131 | // Check the number of arguments |
| 132 | if len(args) != 4 { |
| 133 | return nil, uhaha.ErrWrongNumArgs |
| 134 | } |
| 135 | |
| 136 | // Parse the key and offset |
| 137 | key := []byte(args[1]) |
| 138 | offset, err := strconv.Atoi(args[2]) |
| 139 | if err != nil { |
| 140 | return nil, err |
| 141 | } |
| 142 | |
| 143 | // Parse the value to be set |
| 144 | value := []byte(args[3]) |
| 145 | |
| 146 | // Perform the SetRange operation |
| 147 | n, err := ldb.SetRange(key, offset, value) |
| 148 | if err != nil { |
| 149 | return nil, err |
| 150 | } |
| 151 | |
| 152 | // Return the length of the string after the operation |
| 153 | return redcon.SimpleInt(n), nil |
| 154 | } |
| 155 | |
| 156 | // cmdINCRBY increments the number stored at key by delta. If the key does not exist, |
nothing calls this directly
no outgoing calls
no test coverage detected