Redis ZRANGEBYLEX demo

This is a demo of the new ZRANGEBYLEX Redis command. It autocompletes the query field using all the 8 millions of unique lines of the Linux kernel source code as autocompletion dictionary.

Every time the user types something, the page sends a request to a small PHP snippet called search.php which sends a query to Redis, and returns the result to the web page as a JSON array.
As you type in the input field below, you'll see the list of suggestions appearing.

The javascript was adapted from an example taken from JQuery Autocomplete.


Additional info

The Redis instance uses 1 GB of memory to hold the 8 million unique lines into a sorted set. The search.php script (source code in this Gist) is not very optimized and creates a new Redis connection at every call, but this does not add enough latency for the user to notice. In practice we can auto-complete thousands of simultaneous connections (that likely translates to hundreds of thousands real users, as a connection is created only when the user stops typing something, and immediately destroyed) in real time, with a delay that is mostly the round-trip-time between the client and the web server.

ETA: The new ZRANGEBYLEX command will be available in Redis 2.8.9 before the end of April 2014. It is already available in the 2.8 branch at Github.