Last returns the last valid XID at this timestamp. Useful for the end parameter of XRANGE or XREVRANGE. Note that if the XID used as an end in the range simply based on the timestamp, the sequence number will be zero, so the query will exclude all the items in end second. This will effectively trans
()
| 123 | // so the query will exclude all the items in end second. This will effectively transform the query to '< endTime' |
| 124 | // instead of '<= endTime'. Using Last() prevents this mistake, if that is your intention. |
| 125 | func (xid XID) Last() XID { |
| 126 | timePart := fmt.Sprintf("%020d", xid.Time().Unix()) |
| 127 | return XID(strings.Join([]string{timePart, "99999999999999999999"}, "-")) |
| 128 | } |
| 129 | |
| 130 | type StreamItem struct { |
| 131 | ID XID |