Not really, the database store the data in a file system as well, just that the data format stored is more efficient.

And, typically, the database connection has to go through the network layer which is another resource to consume and database has control and transaction file to maintain.
The advantage of database is exactly for this purpose that it provide transaction control and rollback.
The problem with implementing your own is you need to do the maintenance yourself which is a hassle.
Thus, we should always use readily available implementation.
If your data is huge, cache usually has a limit, which mean it store only a portion of the million records that is being accessed frequently. (another reason why a readily available solution is used)