MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / cmdINCR

Function cmdINCR

strings.go:185–199  ·  view source on GitHub ↗

cmdINCR increments the number stored at key by one. 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)

Source from the content-addressed store, hash-verified

183// it is set to 0 before performing the operation. An error is returned if the key
184// contains a value of the wrong type or contains a string that can not be represented
185// as an integer.
186func cmdINCR(m uhaha.Machine, args []string) (interface{}, error) {
187 // Check the number of arguments
188 if len(args) != 2 {
189 return nil, uhaha.ErrWrongNumArgs
190 }
191
192 // Perform the Incr operation
193 n, err := ldb.Incr([]byte(args[1]))
194 if err != nil {
195 return nil, err
196 }
197
198 // Return the new value after increment
199 return redcon.SimpleInt(n), nil
200}
201
202// cmdGETSET sets the string value of a key and returns its old value. If the key does not exist,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected