In the web world, autocomplete is a method that allows us to quickly look up things that
we want to find without searching. Generally, it works by taking the letters that we’re
typing and finding all words that start with those letters. Some autocomplete tools
will even let us type the beginning of a phrase and finish the phrase for us. As an
example, autocomplete in Google’s search shows us that Betty White’s SNL appearance
is still popular, even years later (which is no surprise—she’s a firecracker). It
shows us the URLs we’ve recently visited and want to revisit when we type in the
address bar, and it helps us remember login names. All of these functions and more
are built to help us access information faster. Some of them, like Google’s search box,
are backed by many terabytes of remote information. Others, like our browser history
and login boxes, are backed by much smaller local databases. But they all get us what
we want with less work.
We’ll build two different types of autocomplete in this section. The first uses lists to
remember the most recent 100 contacts that a user has communicated with, trying to
minimize memory use. Our second autocomplete offers better performance and scalability
for larger lists, but uses more memory per list. They differ in their structure, the
methods used, and the time it takes for the operations to complete. Let’s first start
with an autocomplete for recent contacts.
TRY REDIS ENTERPRISE CLOUD FREE
Redis Enterprise Cloud provides complete automation of day-to-day database operations. Start now with 30MB of free storage.
© 2021 Redis Labs. Redis and the cube logo are registered trademarks of Redis Labs Ltd.