Search code examples
redissortedset

Redis Stream Unique Elements


Could I use Redis Stream as a sorted set? AFAIK Streams do not suppor uniqueueness of each element. If so could I use element ID as uniqueue factor.

For example: insert first element with ID=ABC, then insert one more element with ID=ABC and get an error or it would be replaced (both is suitable for me)

But I have some concerns about performance on the redis side due to algorithmes of element ID storaging, whether it will reorganize inner tree with some extra calculatins?


Solution

  • NO. You CANNOT do that with Redis Stream.

    Apache-Kafka has a similar function, and it can do key compaction to remove stale write. In some scenario, this is a good feature, you can try to submit a feature request to Redis community.