| 742 | } |
| 743 | |
| 744 | func cmdGET(m uhaha.Machine, args []string) (interface{}, error) { |
| 745 | if len(args) != 2 { |
| 746 | return nil, uhaha.ErrWrongNumArgs |
| 747 | } |
| 748 | |
| 749 | // Retrieve the value associated with the key |
| 750 | val, err := ldb.Get([]byte(args[1])) |
| 751 | if err != nil { |
| 752 | return nil, err |
| 753 | } |
| 754 | |
| 755 | // If val is nil, the key does not exist |
| 756 | if val == nil { |
| 757 | return nil, nil |
| 758 | } |
| 759 | |
| 760 | // Return the value if the key exists |
| 761 | return val, nil |
| 762 | } |
| 763 | |
| 764 | // This is different from the RESP standard. For the sake of transaction consistency, there is no key existence judgment. |
| 765 | func cmdDEL(m uhaha.Machine, args []string) (interface{}, error) { |