NuclearPasta
NuclearPasta

Reputation: 1

Redis Streams - Is XADD MAXLEN supposed to update 'max-deleted-entry-id' similar to XTRIM and XDEL?

I had a question regarding the MAXLEN parameter of XADD when dealing with Redis Streams. During my testing I found that using the XDEL commands and using the XTRIM with a MAXLEN parameter commands both update the parameter in XSTREAM INFO, max-deleted-stream-id. However, when I use XADD with the MAXLEN parameter, even in cases where eviction does occur, I do not see max-deleted-stream-id updating. Is this intended functionality, and if so is there any way I can see the last evicted stream id? See sample code below

    import redis
    r = redis.Redis(...)

    entry_ids = []
    for i in range(10):
        entry_id = r.xadd(stream_key, {'field': f'value{i}'})
        entry_ids.append(entry_id)
    
    try:
        r.xgroup_create(stream_key, group_name, id='0', mkstream=True)
    except redis.exceptions.ResponseError as e:
        if "BUSYGROUP" not in str(e):
            raise

    r.xreadgroup(group_name, 'consumer1', {stream_key: '>'}, count=5)
    print(f"BEFORE {r.xinfo_stream(stream_key, full=True)}")
    for i in range(6):
        entry_id = r.xadd(stream_key, {'field': f'value2{i}'}, maxlen= 10, approximate=False)
        entry_ids.append(entry_id)
    print(f"AFTER {r.xinfo_stream(stream_key, full=True)}")

I can see in before and after that new entries are added and entries are evicted, yet max-deleted-stream id remains at "0-0". Any advice would be much appreciated!

Upvotes: 0

Views: 130

Answers (0)

Related Questions