Beating round-trip latency with Redis pipelining
The two approaches for doing this in a timely fashion I considered are as follows:
Without pipelining, when making many requests to a Redis, we are at the mercy of the latency between ourselves and the server in question, or are forced to do threading of some sort. If you’re unsure what a ttl is, the Redis docs do a good job of explaining it, but the long and short of it is that you can set an expiry on a key that Redis stores. This is usually fine for small numbers of keys, but when you’ve got millions, and the Redis you’re talking to is not on your local machine, every single key takes at least the network latency between you and the Redis to retrieve.
Source: kn100.me