This is different from the RESP standard. For the sake of transaction consistency, there is no key existence judgment.
(m uhaha.Machine, args []string)
| 763 | return nil, err |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | return redcon.SimpleString("OK"), nil |
| 768 | } |
| 769 | |
| 770 | // Setex is rewritten as setexat to avoid the exception of raft log playback |
| 771 | func cmdSETEX(m uhaha.Machine, args []string) (interface{}, error) { |
| 772 | if len(args) != 4 { |
| 773 | return nil, uhaha.ErrWrongNumArgs |
| 774 | } |
| 775 | |
| 776 | duration, err := ledis.StrInt64([]byte(args[2]), nil) |
| 777 | if err != nil { |
| 778 | return nil, err |
| 779 | } |
| 780 | timestamp := m.Now().Unix() + duration |
| 781 | |
| 782 | //If the timestamp is less than the current time, delete operation |
| 783 | if timestamp < time.Now().Unix() { |
| 784 | keys := make([][]byte, 1) |
| 785 | keys[0] = []byte(args[1]) |
| 786 | _, err := ldb.Del(keys...) |
| 787 | if err != nil { |
| 788 | return nil, err |
nothing calls this directly
no outgoing calls
no test coverage detected