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

Function cmdAPPEND

strings.go:612–631  ·  view source on GitHub ↗
(m uhaha.Machine, args []string)

Source from the content-addressed store, hash-verified

610 return redcon.SimpleInt(n), nil
611}
612
613func cmdAPPEND(m uhaha.Machine, args []string) (interface{}, error) {
614 // Validate the number of arguments: APPEND requires exactly 3 arguments (command name, key, and value)
615 if len(args) != 3 {
616 return nil, uhaha.ErrWrongNumArgs
617 }
618
619 // Extract the key and value from the arguments
620 key := []byte(args[1]) // Key is at index 1
621 value := []byte(args[2]) // Value is at index 2
622
623 // Perform the APPEND operation: append the value to the key's string
624 n, err := ldb.Append(key, value)
625 if err != nil {
626 // If an error occurs during the append operation, return the error
627 return nil, err
628 }
629
630 // Return the total length of the string after the append operation
631 return redcon.SimpleInt(n), nil
632}
633
634// cmdBITCOUNT handles the BITCOUNT command, which counts the number of set bits (1s) in a string.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected