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

Function cmdGETSET

strings.go:203–217  ·  view source on GitHub ↗

cmdGETSET sets the string value of a key and returns its old value. If the key does not exist, it returns nil. An error is returned if the key contains a value of the wrong type.

(m uhaha.Machine, args []string)

Source from the content-addressed store, hash-verified

201
202// cmdGETSET sets the string value of a key and returns its old value. If the key does not exist,
203// it returns nil. An error is returned if the key contains a value of the wrong type.
204func cmdGETSET(m uhaha.Machine, args []string) (interface{}, error) {
205 // Check the number of arguments
206 if len(args) != 3 {
207 return nil, uhaha.ErrWrongNumArgs
208 }
209
210 // Perform the GetSet operation
211 v, err := ldb.GetSet([]byte(args[1]), []byte(args[2]))
212 if err != nil {
213 return nil, err
214 }
215
216 // Return the old value
217 return v, nil
218}
219
220func cmdGETRANGE(m uhaha.Machine, args []string) (interface{}, error) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected