Service Lifetime

noun

say it: “SUR-vis LYF-tym” /ˈsɝvɪs ˈlaɪfˌtaɪm/

How long a container keeps a part it made: one for the whole app, one per request, or a new one every time.

What is a service lifetime?

A service lifetime says how long a container keeps a part it made: one for the app (made once and shared, often called singleton), one per request (made for each web request and thrown away after, often called scoped), or a new one every time it's asked for (transient). The library's database connection is one for the app; an object that holds who signed in is one per request.

In a sentence

  • “We gave the sign-in details a service lifetime of one per request, so Maya's never leak into Sam's visit.”

Level: Journeyman · More OOP terms at this level

Updated

In other subjects