gpt4 book ai didi

iis - 由 IIS 7 和全局变量(单例)托管的 WCF 服务

转载 作者:行者123 更新时间:2023-12-04 23:56:36 24 4
gpt4 key购买 nike

在我的例子中,我使用 Lucene.Net 进行搜索,并希望使用 IndexReader 和 IndexSearcher 的单个实例。我应该将它们从方法中移到哪里才能为第一个查询实例化一次然后重用。

    public static List<MyType> GetIndexMatches(string fullTextIndexPath, string keyWord ) 
{
IndexSearcher searcher = null;
IndexReader reader = null;
try
{
searcher = new IndexSearcher(fullTextIndexPath);
reader = IndexReader.Open(fullTextIndexPath);
...

最佳答案

您是否尝试过将它们静态化并存在于服务级别(而不是网络方法级别)?

关于iis - 由 IIS 7 和全局变量(单例)托管的 WCF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3261212/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com