For my application, I need an alphabetical index in a set with millions of lines. When I use a sorted set and give all members the same result, the result looks perfect. Performance is also great, with a test set of 2 million lines, the last third is not noticeably less than the first third of the set.
However, I need to request these results. For example, get the first (max.) 100 elements that start with "goo". I played with zscan and sorted, but this does not give me a working and productive result.
Since redis is very fast when inserting a new element into a sorted set, it should be technically possible to immediately (well, very quickly) go to the desired memory location. I suppose redis uses some kind of quicksort mechanism to do this. But .. It seems that I do not get the result when I just want to request data, and not write to it.
We use replicated slaves for read operations, and we prefer (by default) a read-only switch. Thus, creating a dummy key and deleting it after it (no matter how inelegant it is) is not really an option.
I am stuck a bit and I am thinking of writing a ZLEX command in the redis server itself. What could I use like this:
HELP "ZLEX" -> (ZLEX set score startswith)
-- Query the lexicographical index of a sorted set, supplying a 'startswith' string.
127.0.0.1:12345> ZLEX myset 0 goo LIMIT 0 100
1) goo
2) goof
3) goons
4) goozer
What are your thoughts? Am I missing something in the standard redis commands?
We are using Redis 2.8.4 x64 on Debian.
Regards, TW
edits:
:
: indexing-using-redis-sorted-sets → , , ZLEX, , Antirez (Salvatore). 24-1-2014, ZLEX. , , , Antirez .