On top of what @Didier Spezia wrote, I'd also try to store the followers in a sorted set.
If you want them by name, store them all with score of 0, and then use ZRANGEBYLEX to page them lexically.
If you want by the order that they were added as friends, use the timestamp of addition as the score, and use ZRANGE to page them by time.
[EDIT] oh, another option to look at if memory concerns you: if the ids are constant length integers, you can store them as binary values in an array using a string key, and page it with ranges. It will be super fast and will have virtually 0 memory overhead. Have a look at the BITFIELD command. It might be a very good use case for it, although it doesn't cover deletion and lookup, so if those are a concern it's not a good option.
0
Didier Spezia
On
You can try to leverage the SSCAN command. Make sure to understand how the SCAN command works first.
On top of what @Didier Spezia wrote, I'd also try to store the followers in a sorted set.
If you want them by name, store them all with score of 0, and then use ZRANGEBYLEX to page them lexically.
If you want by the order that they were added as friends, use the timestamp of addition as the score, and use ZRANGE to page them by time.
[EDIT] oh, another option to look at if memory concerns you: if the ids are constant length integers, you can store them as binary values in an array using a string key, and page it with ranges. It will be super fast and will have virtually 0 memory overhead. Have a look at the BITFIELD command. It might be a very good use case for it, although it doesn't cover deletion and lookup, so if those are a concern it's not a good option.