简体   繁体   English

创建在IIS7之间托管的WCF服务的请求之间是否还存在?

[英]Create a WCF service hosted in IIS7 alive between request?

How can I keep a WCF service alive between requests? 如何在请求之间使WCF服务保持活动状态? The service is creating a simple cache in memory on initialisation and I dont want the service to have to re-initialise between requests. 该服务在初始化时在内存中创建一个简单的缓存,我不希望该服务在两次请求之间必须重新初始化。 The cache is built up using data extracted from a database and so for efficiency i only need this to be done rarely. 缓存是使用从数据库中提取的数据建立的,因此为了提高效率,我只需要很少这样做。
The database is not going to be updated often and so recycling the app pool every night will suffice in terms of updating the cache. 数据库不会经常更新,因此就每晚更新缓存而言,每晚回收应用程序池就足够了。

You are asking two questions. 您在问两个问题。 If you need service instance alive between requests you should check InstanceContextMode set to PerSession or Single. 如果您需要在请求之间保持活动的服务实例,则应检查InstanceContextMode设置为PerSession还是Single。 If you need application initialization to prepare your shared cache you should check IIS 7.5 Warm-up module and place your initialization to Application_Start in Global.asax. 如果需要应用程序初始化来准备共享缓存,则应检查IIS 7.5预热模块并将初始化放置到Global.asax中的Application_Start中。 For older versions of IIS you have to write some application (console is enough) which will be scheduled to call your web application / service and warm it up. 对于旧版本的IIS,您必须编写一些应用程序(控制台已足够),该应用程序将计划调用您的Web应用程序/服务并对其进行预热。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM