Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lifetime of service instance in ServiceStack?

Tags:

servicestack

I created service derived from

ServiceStack.ServiceInterface.Service

implementing some requests. What is the lifetime of this service instance - e.g. is there created a new instance per call or is the instance cached?

like image 925
eXavier Avatar asked Oct 03 '22 06:10

eXavier


1 Answers

The Services are not singletons. An instance is created with every request.

Take a look at the following test that ensures this ServiceStack / tests / ServiceStack.ServiceHost.Tests / ServiceCreationTests.cs

like image 90
kampsj Avatar answered Oct 07 '22 18:10

kampsj