• Itamar Haber's avatar
    Adds count to L/RPOP (#8179) · f44186e5
    Itamar Haber authored
    Adds: `L/RPOP <key> [count]`
    
    Implements no. 2 of the following strategies:
    
    1. Loop on listTypePop - this would result in multiple calls for memory freeing and allocating (see https://github.com/redis/redis/pull/8179/commits/769167a079b0e110d28e4a8099dce1ecd45682b5)
    2. Iterate the range to build the reply, then call quickListDelRange - this requires two iterations and **is the current choice**
    3. Refactor quicklist to have a pop variant of quickListDelRange - probably optimal but more complex
    
    Also:
    * There's a historical check for NULL after calling listTypePop that was converted to an assert.
    * This refactors common logic shared between LRANGE and the new form of LPOP/RPOP into addListRangeReply (adds test for b/w compat)
    * Consequently, it may have made sense to have `LRANGE l -1 -2` and `LRANGE l 9 0` be legit and return a reverse reply. Due to historical reasons that would be, however, a breaking change.
    * Added minimal comments to existing commands to adhere to the style, make core dev life easier and get commit karma, naturally.
    f44186e5
server.h 121 KB