2

I am new to C# rest API, I have a collection of data that is created when the user POST data into my REST api, What is the best way to keep this data in memory ? The data is stored in a c# collection. I do not have a database to store this day, it must stay in memory for the life of the application.

I hope this is enough information for you guys to point me in the right direction.

1 Answer 1

2

You can achieve saving the data in many forms, but the most straightforward and trivial way will be using Database.

Here are few of the ways of storing information.

  1. Install and use some kind of ORM to talk to your free SQL Server Express MySQL server. - Optimal, but required extra work installing and little to any plumbing.
  2. Use Redis with Nuget .NET Client. - Optimal, but relays on external cache like server
  3. Store the information at the AppDomain, like shown (how to get) similar here - Dirty, and add information to Website RAM and damage performances
  4. Save the information to a static or singleton class which will hold a dictionary for your information. - Add information to Website RAM and damage performances)
  5. Save the objects into files. - Many files hard to handle
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.