Understanding service lifetimes

Let’s take a look at the following points to better understand service lifetimes:

  • Transient, great for lightweight, stateless services are created each time they are requested
  • Scoped, created once per request.
  • Singleton, created the first time they are requested or when ConfigureService is run. Every call subsequent call leverages the same instance.

As we discussed and looked at earlier in the chapter, selecting of your data source is a decision to be based on what you are looking to get out of it. Let’s take another look below. This is how I recommend which system to use, based on functional needs:

Azure ...

Get Hands-On Cloud Solutions with Azure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.