Interface RedisStreamCommands
- All Known Subinterfaces:
DefaultedRedisClusterConnection
,DefaultedRedisConnection
,RedisClusterConnection
,RedisCommands
,RedisConnection
,RedisConnectionUtils.RedisConnectionProxy
,StringRedisConnection
- All Known Implementing Classes:
AbstractRedisConnection
,DefaultStringRedisConnection
,JedisClusterConnection
,JedisConnection
,LettuceClusterConnection
,LettuceConnection
public interface RedisStreamCommands
Stream-specific Redis commands.
- Since:
- 2.2
- Author:
- Mark Paluch, Christoph Strobl, Tugdual Grall, Dengliming, Mark John Moreno
- See Also:
-
Nested Class Summary
Modifier 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, RedisStreamCommands.XAddOptions options) Append the givenrecord
to the stream stored atRecord#getStream
.default List<ByteRecord>
Change the ownership of a pending message to the given new consumer.xClaim
(byte[] key, String group, String newOwner, RedisStreamCommands.XClaimOptions options) Change the ownership of a pending message to the given new consumer.xClaimJustId
(byte[] key, String group, String newOwner, 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[] key, String groupName, ReadOffset readOffset) Create a consumer group.xGroupCreate
(byte[] key, String groupName, ReadOffset readOffset, boolean mkStream) Create a consumer group.default Boolean
xGroupDelConsumer
(byte[] key, String groupName, String consumerName) Delete a consumer from a consumer group.xGroupDelConsumer
(byte[] key, Consumer consumer) Delete a consumer from a consumer group.xGroupDestroy
(byte[] key, String groupName) Destroy a consumer group.xInfo
(byte[] key) Obtain general information about the stream stored at the specified key.xInfoConsumers
(byte[] key, String groupName) Obtain information about every consumer in a specific consumer group for the stream stored at the specified key.xInfoGroups
(byte[] key) Obtain information about consumer groups associated with the stream stored at the specified key.xLen
(byte[] key) Get the length of a stream.Obtain thePendingMessagesSummary
for a given consumer group.default PendingMessages
Obtained detailed information about all pending messages for a given consumer.default PendingMessages
xPending
(byte[] key, String groupName, String consumerName, org.springframework.data.domain.Range<?> range, Long count) Obtain detailed information about pendingmessages
for a givenRange
and consumer within a consumer group.default PendingMessages
Obtain detailed information about pendingmessages
for a givenRange
within a consumer group.xPending
(byte[] key, String groupName, RedisStreamCommands.XPendingOptions options) default PendingMessages
Obtained detailed information about all pending messages for a givenConsumer
.default PendingMessages
default List<ByteRecord>
Retrieve allrecords
within a specificRange
from the stream stored at key.default List<ByteRecord>
xRead
(StreamOffset<byte[]>... streams) Read records from one or moreStreamOffset
s.xRead
(StreamReadOptions readOptions, StreamOffset<byte[]>... streams) Read records from one or moreStreamOffset
s.default List<ByteRecord>
xReadGroup
(Consumer consumer, StreamOffset<byte[]>... streams) Read records from one or moreStreamOffset
s using a consumer group.xReadGroup
(Consumer consumer, StreamReadOptions readOptions, StreamOffset<byte[]>... streams) Read records from one or moreStreamOffset
s using a consumer group.default List<ByteRecord>
Read records from a stream within a specificRange
in reverse order.Read records from a stream within a specificRange
applying aLimit
in reverse order.xTrim
(byte[] key, long count) Trims the stream tocount
elements.xTrim
(byte[] key, long count, boolean approximateTrimming) Trims the stream tocount
elements.
-
Method Details
-
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 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
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
@Nullable RecordId xAdd(MapRecord<byte[], byte[], byte[]> record, 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
@Nullable List<RecordId> xClaimJustId(byte[] key, String group, String newOwner, 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
@Nullable default List<ByteRecord> xClaim(byte[] key, String group, String newOwner, Duration minIdleTime, RecordId... 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
@Nullable List<ByteRecord> xClaim(byte[] key, String group, String newOwner, 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
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
@Nullable String xGroupCreate(byte[] key, String groupName, 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
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
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
@Nullable default PendingMessages xPending(byte[] key, String groupName, org.springframework.data.domain.Range<?> range, Long count) Obtain detailed information about pendingmessages
for a givenRange
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.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
@Nullable default PendingMessages xPending(byte[] key, Consumer consumer, org.springframework.data.domain.Range<?> range, 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
@Nullable default PendingMessages xPending(byte[] key, String groupName, String consumerName, org.springframework.data.domain.Range<?> range, 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
@Nullable PendingMessages xPending(byte[] key, String groupName, 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
@Nullable default List<ByteRecord> xRange(byte[] key, org.springframework.data.domain.Range<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
@Nullable List<ByteRecord> xRange(byte[] key, org.springframework.data.domain.Range<String> range, 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
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
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
@Nullable List<ByteRecord> xReadGroup(Consumer consumer, StreamReadOptions readOptions, StreamOffset<byte[]>... 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
@Nullable default List<ByteRecord> xRevRange(byte[] key, org.springframework.data.domain.Range<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
@Nullable List<ByteRecord> xRevRange(byte[] key, org.springframework.data.domain.Range<String> range, Limit limit) Read records from a stream within a specificRange
applying aLimit
in reverse order.- 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:
-