yurah9001
❔ Asp.net API - the most reasonable in memory storage implementation
Awesome. So as I see it there are two reasonable solutions - either static/singleton class with dictionary or the component you wrote with concurent dictionary, registered as a singleton which brings all the benefits of using DI right?
25 replies
❔ Asp.net API - the most reasonable in memory storage implementation
Sure I definitely agree and understand benefits of dependency injection. We got that sorted out. Which I am now curious about is concurency and one same instance for all requests, sessions. You wrote: "This could then be registered in a singleton fashion for example" I think you must register as a singleton right? Or have this used as a singleton pattern/static to be sure to have only one same instance. Concurency is the other concern I have, therefore I would use ConcurentDictionary but maybe there are better ways or should I need to take care of that?
25 replies
❔ Asp.net API - the most reasonable in memory storage implementation
Awesome now that is where I was heading and what I wanted to hear. First thought was List inside controller, then I thought some static dictionary or singleton somewhere else, then I though maybe better solution would be concurrent dictionary and the latest idea was that I should use dependency injection and register as a singleton. What would the memory class look like then? Still a static or singleton pattern and registered as a singleton? Or am I wrong here?
25 replies
❔ Asp.net API - the most reasonable in memory storage implementation
It could work and maybe underneath works similar from what I described, but caching is something a little bit different for me. I just need to store data for API CRUD in memory using a simple list. Not my idea, of course it is not optimal, but that is what I have to do. So I am looking for the simplest but most correct solution without using advanced components like MemoryCache. Also as I am thinking about it I would like to know the best solution for myself to better understand where I need to use statics, dependency injection, singleton and so on.
25 replies