Reputation: 28511
Does Redis support pushing a list to a list at a given index?
The scenario is simple, pagination. But I don't have any guarantee requests will be performed in a predictable order.
I want to do this:
RPUSH("toSomeListKey", list(value1, value2, value3), startIndex))
E.g. push the values at a known index. A work around would be using setting an index and appending after that known value, but I'd like to avoid the overhead.
Upvotes: 1
Views: 2489
Reputation: 3809
I'm afraid a Redis LIST doesn't support this, and/or is a bad fit for your use case.
Both LINDEX
and LINSERT
are O(N), so you will probably run into performance issues, even if you bundle the commands in a server-side lua script.
I'd consider implementing it as a ZSET
.
Upvotes: 2