Deciding where to keep your data is a tradeoff between speed and RAM usage. Keeping information in the database saves you money, because your game servers need far less RAM. But keeping it in the database means the data will take longer to access, so you can't do it in real-time. When you need to do something which depends on data from the database, you need to wait until the database returned that information, which can take a few ms.
So when you have data you need really fast access to and which you access very frequently, you should keep it in memory.
The positions of currently playing players, for example. You will need those at least once every update tick, so it would be crazy to read those from the database on demand.
But what about the friend list? Well, that depends on what the "friend list" actually does in your particular game.
- Inform players about connect/disconnect events of their friends? That happens every few minutes to every few hours for each player, depending on how sociable they are. It's also no problem at all when these messages appear with a latency of a few seconds. So you could retrieve the friend connections from the database whenever someone connects or disconnects and discard the database result immediately after you posted the events.
- Tell the player where in the world their online friends are currently playing? This means you need to send regular updates to all friends who are also online. Depending on how often you want to send these updates, you might either keep the currently online friends in memory or do it from the database. Keeping the offline friends in memory makes no sense in this particular scenario. But remember to update the online friends list in memory on connect and disconnect events.
- Do you have social game mechanics which actually use the friends list for mechanical reasons? Like, say, people give 10% of their collected experience to all their friends even if the friends are offline? If you had a mechanic like that then it would make sense to keep the complete friends list in memory. But it would not make sense to update their exp count in the database after every exp event. You could just keep track of the exp share of each offline friend in memory and write them to the database at regular intervals.