cmdINCRBY increments the number stored at key by delta. If the key does not exist, it is set to 0 before performing the operation. An error is returned if the key contains a value of the wrong type or contains a string that can not be represented as an integer.
(m uhaha.Machine, args []string)
| 157 | // it is set to 0 before performing the operation. An error is returned if the key |
| 158 | // contains a value of the wrong type or contains a string that can not be represented |
| 159 | // as an integer. |
| 160 | func cmdINCRBY(m uhaha.Machine, args []string) (interface{}, error) { |
| 161 | // Check the number of arguments |
| 162 | if len(args) != 3 { |
| 163 | return nil, uhaha.ErrWrongNumArgs |
| 164 | } |
| 165 | |
| 166 | // Parse the delta value |
| 167 | delta, err := ledis.StrInt64([]byte(args[2]), nil) |
| 168 | if err != nil { |
| 169 | return nil, err |
| 170 | } |
| 171 | |
| 172 | // Perform the IncrBy operation |
| 173 | n, err := ldb.IncrBy([]byte(args[1]), delta) |
| 174 | if err != nil { |
| 175 | return nil, err |
| 176 | } |
| 177 | |
| 178 | // Return the new value after increment |
| 179 | return redcon.SimpleInt(n), nil |
| 180 | } |
| 181 | |
| 182 | // cmdINCR increments the number stored at key by one. If the key does not exist, |
nothing calls this directly
no outgoing calls
no test coverage detected