How to perform lrange + (delete the result of lrange from list) on Redis list

To select and remove the first 100 elements (from the left):

LRANGE list 0 99
LTRIM list 100 -1

To select and remove the last 100 elements (from the right):

LRANGE list -1 -100
LTRIM list 0 -99

From an older version of the redis documentation for LTRIM:

Trim the list name, removing all values not within the slice between start and end. start and end can be negative numbers just like Python slicing notation

Tags:

Caching

Redis