MCPcopy Create free account
hub / github.com/dbProjectRED/redimo.go / Last

Method Last

streams.go:125–128  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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.
125func (xid XID) Last() XID {
126 timePart := fmt.Sprintf("%020d", xid.Time().Unix())
127 return XID(strings.Join([]string{timePart, "99999999999999999999"}, "-"))
128}
129
130type StreamItem struct {
131 ID XID

Callers 1

TestXIDGenerationFunction · 0.80

Calls 2

TimeMethod · 0.95
XIDTypeAlias · 0.85

Tested by 1

TestXIDGenerationFunction · 0.64