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:
  • 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

      Long xAck(byte @NonNull [] key, @NonNull String group, @NonNull RecordId @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 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 given field/value pairs as content to the stream stored at key.
      Parameters:
      key - the key the stream is stored at.
      content - the records content modeled as field/value pairs.
      Returns:
      the server generated id. null when used in pipeline / transaction.
      See Also:
    • xAdd

      default RecordId xAdd(@NonNull MapRecord<byte[],byte[],byte[]> record)
      Append the given record to the stream stored at Record#getStream. If you prefer manual id assignment over server generated ones make sure to provide an id via Record#withId.
      Parameters:
      record - the record to append.
      Returns:
      the id after save. null when used in pipeline / transaction.
    • xAdd

      RecordId xAdd(MapRecord<byte[],byte[],byte[]> record, @NonNull RedisStreamCommands.XAddOptions options)
      Append the given record to the stream stored at Record#getStream. If you prefer manual id assignment over server generated ones make sure to provide an id via Record#withId.
      Parameters:
      record - the record to append.
      options - additional options (eg. MAXLEN). Must not be null, use RedisStreamCommands.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

      default Long xDel(byte @NonNull [] key, @NonNull String @NonNull ... recordIds)
      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

      Long xDel(byte @NonNull [] key, @NonNull RecordId @NonNull ... recordIds)
      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

      Boolean xGroupDelConsumer(byte @NonNull [] key, @NonNull Consumer consumer)
      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

      Boolean xGroupDestroy(byte @NonNull [] key, @NonNull String groupName)
      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

      StreamInfo.XInfoStream xInfo(byte @NonNull [] key)
      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

      StreamInfo.XInfoGroups xInfoGroups(byte @NonNull [] key)
      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

      StreamInfo.XInfoConsumers 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.
      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

      Long xLen(byte @NonNull [] key)
      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

      @Nullable PendingMessagesSummary xPending(byte @NonNull [] key, @NonNull String groupName)
      Obtain the PendingMessagesSummary 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

      default PendingMessages xPending(byte @NonNull [] key, @NonNull Consumer consumer)
      Obtained detailed information about all pending messages for a given Consumer.
      Parameters:
      key - the key the stream is stored at. Must not be null.
      consumer - the consumer to fetch PendingMessages 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 fetch PendingMessages 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)
      Obtain detailed information about pending messages for a given Range 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

      default PendingMessages xPending(byte[] key, String groupName, Range<?> range, Long count, Duration idle)
      Obtain detailed information about pending messages for a given Range within a consumer group and over a given Duration 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 pending messages for a given Range and Consumer within a consumer group.
      Parameters:
      key - the key the stream is stored at. Must not be null.
      consumer - 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 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 pending messages for a given Range and Consumer within a consumer group and over a given Duration of idle time.
      Parameters:
      key - the key the stream is stored at. Must not be null.
      consumer - 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.
      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 pending messages for a given Range 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 pending messages for a given Range and consumer within a consumer group and over a given Duration 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)
      Obtain detailed information about pending messages applying given 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 all records within a specific Range from the stream stored at key.
      Use Range.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 a limited number of records within a specific Range from the stream stored at key.
      Use Range.unbounded() to read from the minimum and the maximum ID possible.
      Use Limit.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

      default List<@NonNull ByteRecord> xRead(StreamOffset<byte @NonNull []> @NonNull ... streams)
      Read records from one or more StreamOffsets.
      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 more StreamOffsets.
      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 more StreamOffsets 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 more StreamOffsets 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 specific Range 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)
      Read records from a stream within a specific Range applying a Limit 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

      Long xTrim(byte @NonNull [] key, long count)
      Trims the stream to count 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

      Long xTrim(byte @NonNull [] key, long count, boolean approximateTrimming)
      Trims the stream to count 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: