• guybe7's avatar
    XADD and XTRIM, Trim by MINID, and new LIMIT argument (#8169) · 814aad65
    guybe7 authored
    This PR adds another trimming strategy to XADD and XTRIM named MINID
    (complements the existing MAXLEN).
    It also adds a new LIMIT argument that allows incremental trimming by repeated
    calls (rather than all at once).
    
    This provides the ability to trim all records older than a certain ID (which makes it
    possible for the user to trim by age too).
    Example:
    XTRIM mystream MINID ~ 1608540753 will trim entries with id < 1608540753,
    but might not trim all (because of the ~ modifier)
    
    The purpose is to ease the use of streams. many users use streams as logs and
    the common case is wanting a log
    of the last X seconds rather than a log that contains maximum X entries (new
    MINID vs existing MAXLEN)
    
    The new LIMIT modifier is only supported when the trim strategy uses ~.
    i.e. when the user asked for exact trimming, it all happens in one go (no
    possibility for incremental trimming).
    However, when ~ is provided, we trim full rax nodes, up to the limit number
    of records.
    The default limit is 100*stream_node_max_entries (used when LIMIT is not
    provided).
    I.e. this is a behavior change (even if the existing MAXLEN strategy is used).
    An explicit limit of 0 means unlimited (but note that it's not the default).
    
    Other changes:
    
    Refactor arg parsing code for XADD and XTRIM to use common code.
    814aad65
t_stream.c 139 KB