If you intend to have your code scalable, then the best thing to do is use a database.
Placing data in a web application statically in the process memory that is serving a request is not good practice . Unless you intend to implement a ObjectCache
that reads and writes to BD yourself, you will be limited to MemoryCache
which does exactly what I said earlier. (there is an implementation of ObjectCache
distributed called NCache
, read below).
But then you could argue that the database is slow ... but the truth is it is not. Most applications read from the database, on all requests. In addition, you can use multi-level caching strategies: using memory and database at the same time, when the need arises.
The question is ... Why not start with the safest? That works in all cases, and then the measure of the need to optimize the cache, migrate to a mixed approach, install a cable between the web server and the BD server, migrate to Azure, Amazon, etc ... there are so many options to optimize this.
Distributed Cache Technologies
They are the best options as they are made to work even in distributed environments.