Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account


pietern opened this Issue Jun 12, 2012 · 7 comments


None yet
7 participants

pietern commented Jun 12, 2012

Or some other command to allow removing a range from a list, instead of keeping a range in a list like LTRIM does.

LTRIM can be implemented by removing a range on the left side, and a range on the right side. The opposite where a range enclosed in the list should be removed cannot be implemented in terms of LTRIM.

See comment section on LTRIM page: http://redis.io/commands/ltrim


antirez commented Feb 5, 2013

This is interesting, but sometimes what you want is to split a list into two keys using this command, so my guess is that we should find a way to STORE the removed elements into a target key.

Anyway scheduling this for 2.8, could be cool to have, this is a fundamental linked list operation that can't be modeled otherwise.

gsilk commented Feb 5, 2013


Where [KEY] is an optional second key to store the spliced elements under?

Dynom commented Mar 13, 2013

LSPLICE would be an extremely useful addition for our case +1 for this feature.


antirez commented Jul 10, 2013

Thinking more about that. We basically want:

  1. An operatin to join two or more lists into a single one.
  2. An operation to move a range of an existing list to another key, or to remove it entirely.

But "2" has two cases, basically, I many want something like LTRIM is currently, but able to move the elements into another list, or I may want to actually remove the elements between the specified indexes, as the original issue states.

I'll try to understand how to implement all this in a way that makes sense from the point of view of the API so that operations are easy enough to understand, not too many commands/variants are added, and all in all, like LTRIM, the commands should make sense as operations that you usually want to run knowing it's going to have limited time complexity, that is, LTRIM is O(N) but usually you LPUSH+LTRIM so it's actually a constant time operation.

All this considered I think we may end with a few really cool things... just unlikely to make it for 2.8

Hailei pushed a commit to Hailei/redis that referenced this issue Aug 29, 2014

Fix #550 : Removed redundant call to connectionPool.getResource() in …
…method getConnectionFromSlot(int slot) in class JedisSlotBasedConnectionHandler

Hailei pushed a commit to Hailei/redis that referenced this issue Aug 29, 2014

Merge pull request #551 from mayankdang/master
Fix #550 : Removed redundant call to connectionPool.getResource()

I fully support this new command, this will make the LIST more like std::list.
And as antirez said, please also consider inserting the trimmed items into a specific position in another LIST.

+1 I need heavily to remove by range and I don't know if ltrim can do that

@gsilk gsilk referenced this issue Jul 19, 2012



+1, i would really like lpop myList 100 to get 100 items, but an implementation of lsplice would work perfectly.

@antirez antirez removed this from the Redis 2.8 milestone May 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment