module Streams
Definitions
def xinfo(*arguments)
Get information on streams and consumer groups. O(N) with N being the number of returned items for the subcommands CONSUMERS and GROUPS. The STREAM subcommand is O(log N) with N being the number of items in the stream.
Implementation
def xinfo(*arguments)
call("XINFO", *arguments)
end
def xadd(*arguments)
Appends a new entry to a stream. O(1).
Implementation
def xadd(*arguments)
call("XADD", *arguments)
end
def xtrim(*arguments)
Trims the stream to (approximately if '~' is passed) a certain size. O(N), with N being the number of evicted entries. Constant times are very small however, since entries are organized in macro nodes containing multiple entries that can be released with a single deallocation.
Implementation
def xtrim(*arguments)
call("XTRIM", *arguments)
end
def xdel(*arguments)
Removes the specified entries from the stream. Returns the number of items actually deleted, that may be different from the number of IDs passed in case certain IDs do not exist. O(1) for each single item to delete in the stream, regardless of the stream size.
Implementation
def xdel(*arguments)
call("XDEL", *arguments)
end
def xrange(*arguments)
Return a range of elements in a stream, with IDs matching the specified IDs interval. O(N) with N being the number of elements being returned. If N is constant (e.g. always asking for the first 10 elements with COUNT), you can consider it O(1).
Implementation
def xrange(*arguments)
call("XRANGE", *arguments)
end
def xrevrange(*arguments)
Return a range of elements in a stream, with IDs matching the specified IDs interval, in reverse order (from greater to smaller IDs) compared to XRANGE. O(N) with N being the number of elements returned. If N is constant (e.g. always asking for the first 10 elements with COUNT), you can consider it O(1).
Implementation
def xrevrange(*arguments)
call("XREVRANGE", *arguments)
end
def xlen(*arguments)
Return the number of entires in a stream. O(1).
Implementation
def xlen(*arguments)
call("XLEN", *arguments)
end
def xread(*arguments)
Return never seen elements in multiple streams, with IDs greater than the ones reported by the caller for each stream. Can block. For each stream mentioned: O(N) with N being the number of elements being returned, it means that XREAD-ing with a fixed COUNT is O(1). Note that when the BLOCK option is used, XADD will pay O(M) time in order to serve the M clients blocked on the stream getting new data.
Implementation
def xread(*arguments)
call("XREAD", *arguments)
end
def xgroup(*arguments)
Create, destroy, and manage consumer groups. O(1) for all the subcommands, with the exception of the DESTROY subcommand which takes an additional O(M) time in order to delete the M entries inside the consumer group pending entries list (PEL).
Implementation
def xgroup(*arguments)
call("XGROUP", *arguments)
end
def xreadgroup(*arguments)
Return new entries from a stream using a consumer group, or access the history of the pending entries for a given consumer. Can block. For each stream mentioned: O(M) with M being the number of elements returned. If M is constant (e.g. always asking for the first 10 elements with COUNT), you can consider it O(1). On the other side when XREADGROUP blocks, XADD will pay the O(N) time in order to serve the N clients blocked on the stream getting new data.
Implementation
def xreadgroup(*arguments)
call("XREADGROUP", *arguments)
end
def xack(*arguments)
Marks a pending message as correctly processed, effectively removing it from the pending entries list of the consumer group. Return value of the command is the number of messages successfully acknowledged, that is, the IDs we were actually able to resolve in the PEL. O(1) for each message ID processed.
Implementation
def xack(*arguments)
call("XACK", *arguments)
end
def xclaim(*arguments)
Changes (or acquires) ownership of a message in a consumer group, as if the message was delivered to the specified consumer. O(log N) with N being the number of messages in the PEL of the consumer group.
Implementation
def xclaim(*arguments)
call("XCLAIM", *arguments)
end
def xpending(*arguments)
Return information and entries from a stream consumer group pending entries list, that are messages fetched but never acknowledged. O(N) with N being the number of elements returned, so asking for a small fixed number of entries per call is O(1). When the command returns just the summary it runs in O(1) time assuming the list of consumers is small, otherwise there is additional O(N) time needed to iterate every consumer.
Implementation
def xpending(*arguments)
call("XPENDING", *arguments)
end