Module: Protocol::Redis::Methods::Streams

Defined in:
lib/protocol/redis/methods/streams.rb

Instance Method Summary collapse

Instance Method Details

#xack(*arguments) ⇒ Object

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.

Parameters:

  • key (Key)
  • group (String)
  • ID (String)

See Also:



115
116
117
# File 'lib/protocol/redis/methods/streams.rb', line 115

def xack(*arguments)
	call("XACK", *arguments)
end

#xadd(*arguments) ⇒ Object

Appends a new entry to a stream. O(1).

Parameters:

  • key (Key)
  • ID (String)

See Also:



38
39
40
# File 'lib/protocol/redis/methods/streams.rb', line 38

def xadd(*arguments)
	call("XADD", *arguments)
end

#xclaim(*arguments) ⇒ Object

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.

Parameters:

  • key (Key)
  • group (String)
  • consumer (String)
  • min-idle-time (String)
  • ID (String)

See Also:



126
127
128
# File 'lib/protocol/redis/methods/streams.rb', line 126

def xclaim(*arguments)
	call("XCLAIM", *arguments)
end

#xdel(*arguments) ⇒ Object

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.

Parameters:

  • key (Key)
  • ID (String)

See Also:



56
57
58
# File 'lib/protocol/redis/methods/streams.rb', line 56

def xdel(*arguments)
	call("XDEL", *arguments)
end

#xgroup(*arguments) ⇒ Object

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).



96
97
98
# File 'lib/protocol/redis/methods/streams.rb', line 96

def xgroup(*arguments)
	call("XGROUP", *arguments)
end

#xinfo(*arguments) ⇒ Object

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.

Parameters:

  • help (Enum)

See Also:



30
31
32
# File 'lib/protocol/redis/methods/streams.rb', line 30

def xinfo(*arguments)
	call("XINFO", *arguments)
end

#xlen(*arguments) ⇒ Object

Return the number of entires in a stream. O(1).

Parameters:

  • key (Key)

See Also:



81
82
83
# File 'lib/protocol/redis/methods/streams.rb', line 81

def xlen(*arguments)
	call("XLEN", *arguments)
end

#xpending(*arguments) ⇒ Object

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.

Parameters:

  • key (Key)
  • group (String)
  • consumer (String)

See Also:



135
136
137
# File 'lib/protocol/redis/methods/streams.rb', line 135

def xpending(*arguments)
	call("XPENDING", *arguments)
end

#xrange(*arguments) ⇒ Object

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).

Parameters:

  • key (Key)
  • start (String)
  • end (String)

See Also:



65
66
67
# File 'lib/protocol/redis/methods/streams.rb', line 65

def xrange(*arguments)
	call("XRANGE", *arguments)
end

#xread(*arguments) ⇒ Object

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.

Parameters:

  • streams (Enum)
  • key (Key)
  • id (String)

See Also:



90
91
92
# File 'lib/protocol/redis/methods/streams.rb', line 90

def xread(*arguments)
	call("XREAD", *arguments)
end

#xreadgroup(*arguments) ⇒ Object

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.

Parameters:

  • noack (Enum)
  • streams (Enum)
  • key (Key)
  • ID (String)

See Also:



106
107
108
# File 'lib/protocol/redis/methods/streams.rb', line 106

def xreadgroup(*arguments)
	call("XREADGROUP", *arguments)
end

#xrevrange(*arguments) ⇒ Object

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).

Parameters:

  • key (Key)
  • end (String)
  • start (String)

See Also:



74
75
76
# File 'lib/protocol/redis/methods/streams.rb', line 74

def xrevrange(*arguments)
	call("XREVRANGE", *arguments)
end

#xtrim(*arguments) ⇒ Object

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.

Parameters:

  • key (Key)
  • strategy (Enum)
  • approx (Enum)
  • count (Integer)

See Also:



48
49
50
# File 'lib/protocol/redis/methods/streams.rb', line 48

def xtrim(*arguments)
	call("XTRIM", *arguments)
end