Search code examples
javascriptmysqlexpressserver

Is storing files for users in my server a bad practice?


Hey there so I have a Express js + React js application. I currently use MySQL for my database management.

In my database I store variables for each user such as their email, password(hashed), and their user id. This works great; however, I wish to make an inventory for the user.

This inventory would be an array where it has values to save the ID of the item they own and the name of it. How would I go about doing this? Should I make something in my database? Or create a text/json file storing those variables to describe their inventory and store it on the server? Any answers will help!


Solution

  • It seems you do not want to compute the inventory each time a user makes a request.

    Well then compute it once and cache the result for that user to prevent the overhead of computing it next time. You have so many options to cache results of your computation. The one I use is redis.

    Once a user makes a request, compute for that request and cache.