Interface RedisStreamCommands
- All Known Subinterfaces:
DefaultedRedisClusterConnection
,DefaultedRedisConnection
,RedisClusterConnection
,RedisCommands
,RedisConnection
,RedisConnectionUtils.RedisConnectionProxy
,StringRedisConnection
- All Known Implementing Classes:
AbstractRedisConnection
,DefaultStringRedisConnection
,JedisClusterConnection
,JedisConnection
,LettuceClusterConnection
,LettuceConnection
@NullUnmarked
public interface RedisStreamCommands
Stream-specific Redis commands.
- Since:
- 2.2
- Author:
- Mark Paluch, Christoph Strobl, Tugdual Grall, Dengliming, Mark John Moreno, Jeonggyu Choi
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Additional options applicable for XADD command.static class
static class
Value Object holding parameters for obtaining pending messages. -
Method Summary
Modifier and TypeMethodDescriptiondefault Long
Acknowledge one or more records, identified via their id, as processed.Acknowledge one or more records, identified via their id, as processed.default RecordId
Append a new record with the givenfield/value pairs
as content to the stream stored atkey
.default RecordId
Append the givenrecord
to the stream stored atRecord#getStream
.xAdd
(MapRecord<byte[], byte[], byte[]> record, @NonNull RedisStreamCommands.XAddOptions options) Append the givenrecord
to the stream stored atRecord#getStream
.default List<@NonNull ByteRecord>
xClaim
(byte @NonNull [] key, @NonNull String group, @NonNull String newOwner, @NonNull Duration minIdleTime, @NonNull RecordId @NonNull ... recordIds) Change the ownership of a pending message to the given new consumer.List<@NonNull ByteRecord>
xClaim
(byte @NonNull [] key, @NonNull String group, @NonNull String newOwner, @NonNull RedisStreamCommands.XClaimOptions options) Change the ownership of a pending message to the given new consumer.xClaimJustId
(byte @NonNull [] key, @NonNull String group, @NonNull String newOwner, @NonNull RedisStreamCommands.XClaimOptions options) Change the ownership of a pending message to the given new consumer without increasing the delivered count.default Long
Removes the records with the given id's from the stream.Removes the records with the given id's from the stream.xGroupCreate
(byte @NonNull [] key, @NonNull String groupName, @NonNull ReadOffset readOffset) Create a consumer group.xGroupCreate
(byte @NonNull [] key, @NonNull String groupName, @NonNull ReadOffset readOffset, boolean mkStream) Create a consumer group.default Boolean
xGroupDelConsumer
(byte @NonNull [] key, @NonNull String groupName, @NonNull String consumerName) Delete a consumer from a consumer group.xGroupDelConsumer
(byte @NonNull [] key, @NonNull Consumer consumer) Delete a consumer from a consumer group.xGroupDestroy
(byte @NonNull [] key, @NonNull String groupName) Destroy a consumer group.xInfo
(byte @NonNull [] key) Obtain general information about the stream stored at the specified key.xInfoConsumers
(byte @NonNull [] key, @NonNull String groupName) Obtain information about every consumer in a specific consumer group for the stream stored at the specified key.xInfoGroups
(byte @NonNull [] key) Obtain information about consumer groups associated with the stream stored at the specified key.xLen
(byte @NonNull [] key) Get the length of a stream.default PendingMessages
xPending
(byte[] key, String groupName, String consumerName, Range<?> range, Long count, Duration idle) default PendingMessages
default PendingMessages
@Nullable PendingMessagesSummary
Obtain thePendingMessagesSummary
for a given consumer group.default PendingMessages
Obtained detailed information about all pending messages for a given consumer.default PendingMessages
xPending
(byte @NonNull [] key, @NonNull String groupName, @NonNull String consumerName, @NonNull Range<?> range, @NonNull Long count) default PendingMessages
xPending
(byte @NonNull [] key, @NonNull String groupName, @NonNull Range<?> range, @NonNull Long count) xPending
(byte @NonNull [] key, @NonNull String groupName, @NonNull RedisStreamCommands.XPendingOptions options) default PendingMessages
Obtained detailed information about all pending messages for a givenConsumer
.default PendingMessages
xPending
(byte @NonNull [] key, @NonNull Consumer consumer, @NonNull Range<?> range, @NonNull Long count) default List<@NonNull ByteRecord>
List<@NonNull ByteRecord>
List<@NonNull ByteRecord>
xRead
(@NonNull StreamReadOptions readOptions, @NonNull StreamOffset<byte[]> @NonNull ... streams) Read records from one or moreStreamOffset
s.default List<@NonNull ByteRecord>
xRead
(StreamOffset<byte @NonNull []> @NonNull ... streams) Read records from one or moreStreamOffset
s.default List<@NonNull ByteRecord>
xReadGroup
(@NonNull Consumer consumer, @NonNull StreamOffset<byte[]> @NonNull ... streams) Read records from one or moreStreamOffset
s using a consumer group.List<@NonNull ByteRecord>
xReadGroup
(@NonNull Consumer consumer, @NonNull StreamReadOptions readOptions, @NonNull StreamOffset<byte[]> @NonNull ... streams) Read records from one or moreStreamOffset
s using a consumer group.default List<@NonNull ByteRecord>
Read records from a stream within a specificRange
in reverse order.List<@NonNull ByteRecord>
xTrim
(byte @NonNull [] key, long count) Trims the stream tocount
elements.xTrim
(byte @NonNull [] key, long count, boolean approximateTrimming) Trims the stream tocount
elements.
-
Method Details
-
xAck
default Long xAck(byte @NonNull [] key, @NonNull String group, @NonNull String @NonNull ... recordIds) Acknowledge one or more records, identified via their id, as processed.- Parameters:
key
- the key the stream is stored at.group
- name of the consumer group.recordIds
- the String representation of the id's of the records to acknowledge.- Returns:
- length of acknowledged messages. null when used in pipeline / transaction.
- See Also:
-
xAck
Acknowledge one or more records, identified via their id, as processed.- Parameters:
key
- the key the stream is stored at.group
- name of the consumer group.recordIds
- the id's of the records to acknowledge.- Returns:
- length of acknowledged messages. null when used in pipeline / transaction.
- See Also:
-
xAdd
default RecordId xAdd(byte @NonNull [] key, @NonNull Map<byte @NonNull [], byte @NonNull []> content) Append a new record with the givenfield/value pairs
as content to the stream stored atkey
.- Parameters:
key
- the key the stream is stored at.content
- the records content modeled asfield/value pairs
.- Returns:
- the server generated
id
. null when used in pipeline / transaction. - See Also:
-
xAdd
Append the givenrecord
to the stream stored atRecord#getStream
. If you prefer manual id assignment over server generated ones make sure to provide an id viaRecord#withId
. -
xAdd
RecordId xAdd(MapRecord<byte[], byte[], byte[]> record, @NonNull RedisStreamCommands.XAddOptions options) Append the givenrecord
to the stream stored atRecord#getStream
. If you prefer manual id assignment over server generated ones make sure to provide an id viaRecord#withId
.- Parameters:
record
- therecord
to append.options
- additional options (eg. MAXLEN). Must not be null, useRedisStreamCommands.XAddOptions.none()
instead.- Returns:
- the
id
after save. null when used in pipeline / transaction. - Since:
- 2.3
-
xClaimJustId
List<@NonNull RecordId> xClaimJustId(byte @NonNull [] key, @NonNull String group, @NonNull String newOwner, @NonNull RedisStreamCommands.XClaimOptions options) Change the ownership of a pending message to the given new consumer without increasing the delivered count.- Parameters:
key
- the key the stream is stored at.group
- the name of the consumer group.newOwner
- the name of the new consumer.options
- must not be null.- Returns:
- list of
ids
that changed user. - Since:
- 2.3
- See Also:
-
xClaim
default List<@NonNull ByteRecord> xClaim(byte @NonNull [] key, @NonNull String group, @NonNull String newOwner, @NonNull Duration minIdleTime, @NonNull RecordId @NonNull ... recordIds) Change the ownership of a pending message to the given new consumer.- Parameters:
key
- the key the stream is stored at.group
- the name of the consumer group.newOwner
- the name of the new consumer.minIdleTime
- must not be null.recordIds
- must not be null.- Returns:
- list of
ByteRecord
that changed user. - Since:
- 2.3
- See Also:
-
xClaim
List<@NonNull ByteRecord> xClaim(byte @NonNull [] key, @NonNull String group, @NonNull String newOwner, @NonNull RedisStreamCommands.XClaimOptions options) Change the ownership of a pending message to the given new consumer.- Parameters:
key
- the key the stream is stored at.group
- the name of the consumer group.newOwner
- the name of the new consumer.options
- must not be null.- Returns:
- list of
ByteRecord
that changed user. - Since:
- 2.3
- See Also:
-
xDel
Removes the records with the given id's from the stream. Returns the number of items deleted, that may be different from the number of id's passed in case certain id's do not exist.- Parameters:
key
- the key the stream is stored at.recordIds
- the id's of the records to remove.- Returns:
- number of removed entries. null when used in pipeline / transaction.
- See Also:
-
xDel
Removes the records with the given id's from the stream. Returns the number of items deleted, that may be different from the number of id's passed in case certain id's do not exist.- Parameters:
key
- the key the stream is stored at.recordIds
- the id's of the records to remove.- Returns:
- number of removed entries. null when used in pipeline / transaction.
- See Also:
-
xGroupCreate
String xGroupCreate(byte @NonNull [] key, @NonNull String groupName, @NonNull ReadOffset readOffset) Create a consumer group.- Parameters:
key
- the key the stream is stored at.groupName
- name of the consumer group to create.readOffset
- the offset to start at.- Returns:
- ok if successful. null when used in pipeline / transaction.
-
xGroupCreate
String xGroupCreate(byte @NonNull [] key, @NonNull String groupName, @NonNull ReadOffset readOffset, boolean mkStream) Create a consumer group.- Parameters:
key
- the key the stream is stored at.groupName
- name of the consumer group to create.readOffset
- the offset to start at.mkStream
- if true the group will create the stream if not already present (MKSTREAM)- Returns:
- ok if successful. null when used in pipeline / transaction.
- Since:
- 2.3
-
xGroupDelConsumer
default Boolean xGroupDelConsumer(byte @NonNull [] key, @NonNull String groupName, @NonNull String consumerName) Delete a consumer from a consumer group.- Parameters:
key
- the key the stream is stored at.groupName
- the name of the group to remove the consumer from.consumerName
- the name of the consumer to remove from the group.- Returns:
- true if successful. null when used in pipeline / transaction.
-
xGroupDelConsumer
Delete a consumer from a consumer group.- Parameters:
key
- the key the stream is stored at.consumer
- consumer identified by group name and consumer name.- Returns:
- true if successful. null when used in pipeline / transaction.
-
xGroupDestroy
Destroy a consumer group.- Parameters:
key
- the key the stream is stored at.groupName
- name of the consumer group.- Returns:
- true if successful. null when used in pipeline / transaction.
-
xInfo
Obtain general information about the stream stored at the specified key.- Parameters:
key
- the key the stream is stored at.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.3
-
xInfoGroups
Obtain information about consumer groups associated with the stream stored at the specified key.- Parameters:
key
- the key the stream is stored at.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.3
-
xInfoConsumers
Obtain information about every consumer in a specific consumer group for the stream stored at the specified key.- Parameters:
key
- the key the stream is stored at.groupName
- name of the consumer group.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.3
-
xLen
Get the length of a stream.- Parameters:
key
- the key the stream is stored at.- Returns:
- length of the stream. null when used in pipeline / transaction.
- See Also:
-
xPending
Obtain thePendingMessagesSummary
for a given consumer group.- Parameters:
key
- the key the stream is stored at. Must not be null.groupName
- the name of the consumer group. Must not be null.- Returns:
- a summary of pending messages within the given consumer group or null when used in pipeline / transaction.
- Since:
- 2.3
- See Also:
-
xPending
Obtained detailed information about all pending messages for a givenConsumer
.- Parameters:
key
- the key the stream is stored at. Must not be null.consumer
- the consumer to fetchPendingMessages
for. Must not be null.- Returns:
- pending messages for the given
Consumer
or null when used in pipeline / transaction. - Since:
- 2.3
- See Also:
-
xPending
default PendingMessages xPending(byte @NonNull [] key, @NonNull String groupName, @NonNull String consumerName) Obtained detailed information about all pending messages for a given consumer.- Parameters:
key
- the key the stream is stored at. Must not be null.groupName
- the name of the consumer group. Must not be null.consumerName
- the consumer to fetchPendingMessages
for. Must not be null.- Returns:
- pending messages for the given
Consumer
or null when used in pipeline / transaction. - Since:
- 2.3
- See Also:
-
xPending
default PendingMessages xPending(byte @NonNull [] key, @NonNull String groupName, @NonNull Range<?> range, @NonNull Long count) - Parameters:
key
- the key the stream is stored at. Must not be null.groupName
- the name of the consumer group. Must not be null.range
- the range of messages ids to search within. Must not be null.count
- limit the number of results. Must not be null.- Returns:
- pending messages for the given consumer group or null when used in pipeline / transaction.
- Since:
- 2.3
- See Also:
-
xPending
default PendingMessages xPending(byte[] key, String groupName, Range<?> range, Long count, Duration idle) Obtain detailed information about pendingmessages
for a givenRange
within a consumer group and over a givenDuration
of idle time.- Parameters:
key
- the key the stream is stored at. Must not be null.groupName
- the name of the consumer group. Must not be null.range
- the range of messages ids to search within. Must not be null.count
- limit the number of results. Must not be null.idle
- the minimum idle time to filter pending messages. Must not be null.- Returns:
- pending messages for the given consumer group or null when used in pipeline / transaction.
- Since:
- 4.0
- See Also:
-
xPending
default PendingMessages xPending(byte @NonNull [] key, @NonNull Consumer consumer, @NonNull Range<?> range, @NonNull Long count) Obtain detailed information about pendingmessages
for a givenRange
andConsumer
within a consumer group.- Parameters:
key
- the key the stream is stored at. Must not be null.consumer
- the name of theConsumer
. Must not be null.range
- the range of messages ids to search within. Must not be null.count
- limit the number of results. Must not be null.- Returns:
- pending messages for the given
Consumer
or null when used in pipeline / transaction. - Since:
- 2.3
- See Also:
-
xPending
default PendingMessages xPending(byte[] key, Consumer consumer, Range<?> range, Long count, Duration minIdleTime) Obtain detailed information about pendingmessages
for a givenRange
andConsumer
within a consumer group and over a givenDuration
of idle time.- Parameters:
key
- the key the stream is stored at. Must not be null.consumer
- the name of theConsumer
. Must not be null.range
- the range of messages ids to search within. Must not be null.count
- limit the number of results. Must not be null.minIdleTime
- the minimum idle time to filter pending messages. Must not be null.- Returns:
- pending messages for the given
Consumer
or null when used in pipeline / transaction. - Since:
- 4.0
- See Also:
-
xPending
default PendingMessages xPending(byte @NonNull [] key, @NonNull String groupName, @NonNull String consumerName, @NonNull Range<?> range, @NonNull Long count) Obtain detailed information about pendingmessages
for a givenRange
and consumer within a consumer group.- Parameters:
key
- the key the stream is stored at. Must not be null.groupName
- the name of the consumer group. Must not be null.consumerName
- the name of the consumer. Must not be null.range
- the range of messages ids to search within. Must not be null.count
- limit the number of results. Must not be null.- Returns:
- pending messages for the given consumer in given consumer group or null when used in pipeline / transaction.
- Since:
- 2.3
- See Also:
-
xPending
default PendingMessages xPending(byte[] key, String groupName, String consumerName, Range<?> range, Long count, Duration idle) Obtain detailed information about pendingmessages
for a givenRange
and consumer within a consumer group and over a givenDuration
of idle time.- Parameters:
key
- the key the stream is stored at. Must not be null.groupName
- the name of the consumer group. Must not be null.consumerName
- the name of the consumer. Must not be null.range
- the range of messages ids to search within. Must not be null.count
- limit the number of results. Must not be null.idle
- the minimum idle time to filter pending messages. Must not be null.- Returns:
- pending messages for the given consumer in given consumer group or null when used in pipeline / transaction.
- Since:
- 4.0
- See Also:
-
xPending
PendingMessages xPending(byte @NonNull [] key, @NonNull String groupName, @NonNull RedisStreamCommands.XPendingOptions options) - Parameters:
key
- the key the stream is stored at. Must not be null.groupName
- the name of the consumer group. Must not be null.options
- the options containing range, consumer and count. Must not be null.- Returns:
- pending messages matching given criteria or null when used in pipeline / transaction.
- Since:
- 2.3
- See Also:
-
xRange
default List<@NonNull ByteRecord> xRange(byte @NonNull [] key, @NonNull Range<@NonNull String> range) Retrieve allrecords
within a specificRange
from the stream stored at key.
UseRange.unbounded()
to read from the minimum and the maximum ID possible.- Parameters:
key
- the key the stream is stored at.range
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
xRange
List<@NonNull ByteRecord> xRange(byte @NonNull [] key, @NonNull Range<@NonNull String> range, @NonNull Limit limit) Retrieve alimited number
ofrecords
within a specificRange
from the stream stored at key.
UseRange.unbounded()
to read from the minimum and the maximum ID possible.
UseLimit.unlimited()
to read all records.- Parameters:
key
- the key the stream is stored at.range
- must not be null.limit
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
xRead
Read records from one or moreStreamOffset
s.- Parameters:
streams
- the streams to read from.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
xRead
List<@NonNull ByteRecord> xRead(@NonNull StreamReadOptions readOptions, @NonNull StreamOffset<byte[]> @NonNull ... streams) Read records from one or moreStreamOffset
s.- Parameters:
readOptions
- read arguments.streams
- the streams to read from.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
xReadGroup
default List<@NonNull ByteRecord> xReadGroup(@NonNull Consumer consumer, @NonNull StreamOffset<byte[]> @NonNull ... streams) Read records from one or moreStreamOffset
s using a consumer group.- Parameters:
consumer
- consumer/group.streams
- the streams to read from.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
xReadGroup
List<@NonNull ByteRecord> xReadGroup(@NonNull Consumer consumer, @NonNull StreamReadOptions readOptions, @NonNull StreamOffset<byte[]> @NonNull ... streams) Read records from one or moreStreamOffset
s using a consumer group.- Parameters:
consumer
- consumer/group.readOptions
- read arguments.streams
- the streams to read from.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
xRevRange
default List<@NonNull ByteRecord> xRevRange(byte @NonNull [] key, @NonNull Range<@NonNull String> range) Read records from a stream within a specificRange
in reverse order.- Parameters:
key
- the stream key.range
- must not be null.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
xRevRange
List<@NonNull ByteRecord> xRevRange(byte @NonNull [] key, @NonNull Range<@NonNull String> range, @NonNull Limit limit) - Parameters:
key
- the stream key.range
- must not be null.limit
- must not be null.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
xTrim
Trims the stream tocount
elements.- Parameters:
key
- the stream key.count
- length of the stream.- Returns:
- number of removed entries. null when used in pipeline / transaction.
- See Also:
-
xTrim
Trims the stream tocount
elements.- Parameters:
key
- the stream key.count
- length of the stream.approximateTrimming
- the trimming must be performed in a approximated way in order to maximize performances.- Returns:
- number of removed entries. null when used in pipeline / transaction.
- Since:
- 2.4
- See Also:
-