Ejemplo n.º 1
0
        public static OpenSearchEngine GetNewOpenSearchEngine()
        {
            var newOse = new OpenSearchEngine();
            AtomOpenSearchEngineExtension aosee = new AtomOpenSearchEngineExtension();

            newOse.RegisterExtension(aosee);
            FeatureCollectionOpenSearchEngineExtension ngosee = new FeatureCollectionOpenSearchEngineExtension();

            newOse.RegisterExtension(ngosee);

            var slidingExpiration = "30";

            if (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["Opensearch.Cache.SlidingExpiration"]))
            {
                slidingExpiration = System.Configuration.ConfigurationManager.AppSettings["Opensearch.Cache.SlidingExpiration"];
            }

            if (slidingExpiration != "0")
            {
                NameValueCollection nvc = new NameValueCollection();
                nvc.Add("SlidingExpiration", slidingExpiration);
                searchCache = new OpenSearchMemoryCache("cache", nvc);
                newOse.RegisterPreSearchFilter(searchCache.TryReplaceWithCacheRequest);
                newOse.RegisterPostSearchFilter(searchCache.CacheResponse);
            }
            return(newOse);
        }
        private void InitCache()
        {
            NameValueCollection cacheSettings = new NameValueCollection();

            cacheSettings.Add("SlidingExpiration", "600");

            searchCache = new OpenSearchMemoryCache("cache", cacheSettings);
            ose.RegisterPreSearchFilter(searchCache.TryReplaceWithCacheRequest);
            ose.RegisterPostSearchFilter(searchCache.CacheResponse);
        }
Ejemplo n.º 3
0
        private void LoadStaticObject()
        {
            OpenSearchEngine = new OpenSearchEngine();
            OpenSearchEngine.LoadPlugins();

            NameValueCollection cacheSettings = new NameValueCollection();

            cacheSettings.Add("SlidingExpiration", "600");

            AppHost.searchCache = new OpenSearchMemoryCache("cache", cacheSettings);
            OpenSearchEngine.RegisterPreSearchFilter(AppHost.searchCache.TryReplaceWithCacheRequest);
            OpenSearchEngine.RegisterPostSearchFilter(AppHost.searchCache.CacheResponse);

            ElasticCasFactory.LoadPlugins(this);
        }