Search code examples
c#asp.net-corememory-management

Any good solution for store variable?


I want to store a variable sent from frontend (ReactJs) to my backend (asp.net core) for example this URL: http://localhost:3000/?inviteCode=TRIAL, I want to store the value TRIAL in any place (the backend is a higher priority) to use later.

The things made me confused I choosing which way to store it. I don't want to store it in the InMemory Store (memcache) because I've used it in many places and this could cause out of memory on the host VM (I think so). Store it in the database is not a good idea to store a little value like this.

Store it in frontend cookies or local storage is a good solution but my priority is to store it in the backend.

So are there any solutions to store this value?


Solution

  • It looks like the only way left is another database on the same physical server as the application server (I'm assuming your current database is remote). SQLite might be the easiest option.

    But in general, you will probably need this value in the future, in which case it's better to save it to a database right away.

    If not, then think again, whether these queries will really be so many to constantly overflow the VM (one-time overflow is not terrible, the operating system can handle it). And can you enlarge the VM as needed?

    As a compromise, you could put memcache on a separate server.