Hello, consider a social media platform where we have a search bar. Normally, let say we are looking for a person John Doe. When we first type John, without even having to press enter, there are a list of suggestions that appear. I was wondering how does that work?
I might have some ideas:
The ineffective one:
There is kind of an infinite loop that triggers and send request each time the state of the search bar is changed.
Another one is maybe (a bit more effective I guess), store every user somewhere, like in the cache, I know we use Redis to cache info? So maybe instead of always sending a request to the server, just cache the users and look from there? Maybe we try to invalidate the cache and fetch a new one at regular time interval or when particular actions are triggered?